Compare commits
627 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 026559ecaa | |||
| 54ca0e0207 | |||
| dc0a271adf | |||
| a4858d47fc | |||
| e73091cdf3 | |||
| c8773c8c45 | |||
| 598302925b | |||
| 1870f3d9b6 | |||
| 58fd97511e | |||
| c826edcbc1 | |||
| ea07b49995 | |||
| aa05ca0043 | |||
| 1c5a3b2c08 | |||
| 3a2e51027f | |||
| 9671f2e37f | |||
| 330e2772a9 | |||
| 9f6892f973 | |||
| f09db7aa97 | |||
| 7c8d5432ba | |||
| 5b61c68811 | |||
| 4d09418cfd | |||
| 9991a4bdd8 | |||
| 266c90cd09 | |||
| 7f7dca16c0 | |||
| ccf52a6623 | |||
| 5e798e7f05 | |||
| 28fbc40f70 | |||
| ea881adbd2 | |||
| 314e519937 | |||
| 3fc247e8e5 | |||
| ebdfd04105 | |||
| 4fc571e5e2 | |||
| 3957e831f9 | |||
| eef23f6bba | |||
| c7fb6078a9 | |||
| a0ea15ef2a | |||
| f635515d61 | |||
| a3b3bd04ef | |||
| f9d9a1bf5c | |||
| 06c5df0207 | |||
| 917d95f5f3 | |||
| 89e6c023db | |||
| d2baceadea | |||
| 93d75a4ef3 | |||
| 07d631a7bb | |||
| c232caf2f0 | |||
| 20a6ecffa6 | |||
| 08cc1dabd8 | |||
| 3741278825 | |||
| 4a77c59baf | |||
| 96f236a433 | |||
| fca4eb5fd1 | |||
| 92a63551c6 | |||
| 11ada68d54 | |||
| d3003db0f8 | |||
| e233c814e7 |
29
.env
29
.env
@@ -1,24 +1,28 @@
|
||||
[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 = 81.70.45.221
|
||||
database = super_chat
|
||||
username = super_chat
|
||||
password = c7NXx8KMPaTX4N5W
|
||||
#测试
|
||||
hostname = 1.13.181.248
|
||||
database = yusheng
|
||||
username = yusheng
|
||||
password = GEDYGj3HbZfKYBjp
|
||||
hostport = 3306
|
||||
prefix = fa_
|
||||
|
||||
#正式
|
||||
#hostname = 1.13.101.98
|
||||
#database = yusheng
|
||||
#username = yusheng
|
||||
#password = GEDYGj3HbZfKYBjp
|
||||
#hostport = 3306
|
||||
#prefix = fa_
|
||||
|
||||
[mqtt]
|
||||
mqtt_server = 81.70.45.221
|
||||
mqtt_server = 1.13.181.248
|
||||
mqtt_port = 1883
|
||||
mqtt_username = admin
|
||||
mqtt_password = public
|
||||
@@ -32,6 +36,7 @@ dxb_temp = "【羽声语音】您的验证码是{code}。如非本人操作,
|
||||
[wechatpay]
|
||||
mch_id = 1719907761
|
||||
appid = wxc7681513be9f926b
|
||||
#下面具体是V2秘钥
|
||||
api_v3_key = "5826Qxhs456453614dsjkfhdsf53g4op"
|
||||
serial_no = "51FAD3F779271A865040771BEC14A825638E9484"
|
||||
private_key = "epay/certs/apiclient_key.pem"
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,4 +2,6 @@
|
||||
/public/uploads/*
|
||||
.idea
|
||||
*.log
|
||||
|
||||
.env
|
||||
.node_modules
|
||||
node_modules/
|
||||
|
||||
@@ -40,8 +40,9 @@ class Activities extends adminApi
|
||||
public function first_charge_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$activities_id = input('activities_id', 1);
|
||||
$where = [];
|
||||
$where['activities_id'] = 1;
|
||||
$where['activities_id'] = $activities_id;
|
||||
$where['delete_time'] = 0;
|
||||
$count = db($this->table)->where($where)->count();
|
||||
$lists = db($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
@@ -76,11 +77,12 @@ class Activities extends adminApi
|
||||
$title1 = input('title1', '');
|
||||
$title2 = input('title2', '');
|
||||
$money = input('money', '');
|
||||
$activities_id = input('activities_id', 1);
|
||||
$return_data = [
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'status' => $status,
|
||||
'activities_id' => 1,
|
||||
'activities_id' => $activities_id,
|
||||
];
|
||||
$ext = [
|
||||
'title1' => $title1,
|
||||
@@ -167,11 +169,12 @@ class Activities extends adminApi
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$activities_id = input('activities_id', 1);
|
||||
$where = [];
|
||||
if($user_id){
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
$gift_bag = db('vs_gift_bag')->where(['activities_id'=>1,'delete_time'=>0])->select();
|
||||
$gift_bag = db('vs_gift_bag')->where(['activities_id'=>$activities_id,'delete_time'=>0])->select();
|
||||
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
@@ -360,6 +363,7 @@ class Activities extends adminApi
|
||||
'foreign_id' => $gift_id,
|
||||
'name' => $gift['gift_name'],
|
||||
'quantity' => $num,
|
||||
'gold' => $gift['gift_price'],
|
||||
];
|
||||
} elseif($type == 3){
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$gift_id])->find();
|
||||
@@ -373,6 +377,7 @@ class Activities extends adminApi
|
||||
'foreign_id' => $gift_id,
|
||||
'name' => $gift['title'],
|
||||
'days' => $decorate_price['day'],
|
||||
'gold' => $decorate_price['price'],
|
||||
];
|
||||
} elseif($type == 4){
|
||||
$data = [
|
||||
@@ -419,6 +424,7 @@ class Activities extends adminApi
|
||||
'money' => $ext['money'],
|
||||
'money_str' => $ext['money_str'],
|
||||
'diamond' => $ext['diamond'],
|
||||
'activity_end_time' => $ext['activity_end_time'],
|
||||
];
|
||||
return V(1,"成功",$data);
|
||||
}
|
||||
@@ -433,17 +439,20 @@ class Activities extends adminApi
|
||||
$money = input('money', '');
|
||||
$money_str = input('money_str', '');
|
||||
$diamond = input('diamond', '');
|
||||
$activity_end_time = input('activity_end_time', '');
|
||||
$id = input('id', 6);
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'title' => $title,
|
||||
'status' => $status
|
||||
'status' => $status,
|
||||
'money' => $money,
|
||||
];
|
||||
$ext = [
|
||||
'counter' => $counter,
|
||||
'money_str' => $money_str,
|
||||
'diamond' => $diamond,
|
||||
'money' => $money
|
||||
'money' => $money,
|
||||
'activity_end_time' => $activity_end_time
|
||||
];
|
||||
$data['ext'] = json_encode($ext);
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
@@ -498,6 +507,7 @@ class Activities extends adminApi
|
||||
$meet = input('meet','');
|
||||
$num = input('num', 0);
|
||||
$content = input('content', 0);
|
||||
$title = input('title', "");
|
||||
if($gift_bag_id==""){
|
||||
return V(0,"请选择礼包类型");
|
||||
}
|
||||
@@ -516,6 +526,7 @@ class Activities extends adminApi
|
||||
'num' => $num
|
||||
];
|
||||
$data['ext'] = json_encode($ext);
|
||||
$data['title'] = $title;
|
||||
$res = db::name($this->table)->where(['id'=>$gift_bag_id])->update($data);
|
||||
if(!$res){
|
||||
return V(0,"失败");
|
||||
@@ -591,10 +602,10 @@ class Activities 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();
|
||||
$lists[$key]['base_image'] = $gift_data['base_image'];
|
||||
$lists[$key]['base_image'] = $gift_data['base_image']??"";
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['quantity_str'] = $value['quantity']."个";
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price']?? "";
|
||||
}elseif ($value['type'] == 3){
|
||||
$lists[$key]['gift_id'] = $value['foreign_id'];
|
||||
$lists[$key]['gift_name'] = $value['name'];
|
||||
@@ -689,15 +700,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);
|
||||
|
||||
@@ -168,7 +168,7 @@ class Admin extends adminApi
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post();
|
||||
$group = $params['group'];
|
||||
$group = $params['group']?? [];
|
||||
unset($params['group']);
|
||||
unset($params['__token__']);
|
||||
if ($params) {
|
||||
@@ -196,21 +196,21 @@ class Admin extends adminApi
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
|
||||
// 先移除所有权限
|
||||
model('admin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
||||
if(!empty($group)){
|
||||
// 先移除所有权限
|
||||
model('admin/AuthGroupAccess')->where('uid', $params['id'])->delete();
|
||||
// 过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
if (!$group) {
|
||||
return V(0,"失败", []);
|
||||
}
|
||||
|
||||
|
||||
// 过滤不允许的组别,避免越权
|
||||
$group = array_intersect($this->childrenGroupIds, $group);
|
||||
if (!$group) {
|
||||
return V(0,"失败", []);
|
||||
$dataset = [];
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $params['id'], 'group_id' => $value];
|
||||
}
|
||||
model('admin/AuthGroupAccess')->saveAll($dataset);
|
||||
}
|
||||
|
||||
$dataset = [];
|
||||
foreach ($group as $value) {
|
||||
$dataset[] = ['uid' => $params['id'], 'group_id' => $value];
|
||||
}
|
||||
model('admin/AuthGroupAccess')->saveAll($dataset);
|
||||
Db::commit();
|
||||
return V(1,"成功", []);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -52,10 +52,10 @@ class Adminlog extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($search_stime)];
|
||||
}
|
||||
if ($search_etime) {
|
||||
$where['createtime'] = ['<=', strtotime($search_etime.' 23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($search_etime)];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime)]];
|
||||
}
|
||||
|
||||
$list_data = $this->model->where($where)->where('admin_id', 'in', $this->childrenAdminIds)->order('createtime', 'desc')->paginate($page_limit, false, ['page' => $page]);
|
||||
|
||||
@@ -151,7 +151,7 @@ class Banner extends adminApi
|
||||
$image = input('image', '');
|
||||
$show_status = input('show_status', '');
|
||||
$remarks = input('remarks', '');
|
||||
$content = input('content', '');
|
||||
$content =$_POST['content']??"";
|
||||
if (!$id){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
use think\Cache;
|
||||
|
||||
/**
|
||||
* 盲盒
|
||||
@@ -18,7 +19,7 @@ class BlindBox extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['blind_box_type','blind_box_gifts'];
|
||||
protected $noNeedRight = ['blind_box_type','blind_box_gifts','xunlehui_rule_detail','xunlehui_set_rule','blind_box_turntable_lists','blind_box_turntable_open_record','xlh_lock_record'];
|
||||
|
||||
protected $table = 'vs_gift_bag_detail';
|
||||
|
||||
@@ -40,7 +41,8 @@ class BlindBox extends adminApi
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>4,'status'=>1])->select();
|
||||
$bag_data = db::name("vs_gift_bag")->find($gift_bag_id);
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$bag_data['activities_id'],'status'=>1])->select();
|
||||
foreach ($bag_list as &$v) {
|
||||
$v['default'] = $gift_bag_id == $v['id'] ? 1 : 0;
|
||||
}
|
||||
@@ -60,15 +62,21 @@ 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();
|
||||
$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]['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']);
|
||||
|
||||
}
|
||||
//$lists 按gift_price 降序排序
|
||||
usort($lists, function($a, $b) {
|
||||
return $b['gift_price'] - $a['gift_price'];
|
||||
});
|
||||
//统计
|
||||
$total_data = [];
|
||||
//每期总次数
|
||||
@@ -83,9 +91,14 @@ class BlindBox extends adminApi
|
||||
//每期总抽奖花费(支出)
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,name,ext')->where(['id'=>$gift_bag_id])->find();
|
||||
$ext = json_decode($bag_data['ext'],true);
|
||||
$c_gift_id = $ext['gift_id'];
|
||||
$c_gift_data = db::name('vs_gift')->where(['gid'=>$c_gift_id])->find();
|
||||
$gift_price = $c_gift_data['gift_price']??0;
|
||||
|
||||
if($gift_bag_id == 13){
|
||||
$gift_price = $ext['xlh_box_price']??0;
|
||||
}else{
|
||||
$c_gift_id = $ext['gift_id'];
|
||||
$c_gift_data = db::name('vs_gift')->where(['gid'=>$c_gift_id])->find();
|
||||
$gift_price = $c_gift_data['gift_price']??0;
|
||||
}
|
||||
$total_cost = $total_count * $gift_price;
|
||||
//每期统计(收入/支出)
|
||||
if($total_cost==0 || $total_price==0){
|
||||
@@ -131,6 +144,8 @@ class BlindBox extends adminApi
|
||||
$gift_id = input('gift_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$quantity = input('quantity', 0);
|
||||
$weight = input('weight', 0);
|
||||
$is_world_show = input('is_world_show', 0);
|
||||
if(empty($gift_id)){
|
||||
return V(0,"请选择礼物");
|
||||
}
|
||||
@@ -153,6 +168,9 @@ class BlindBox extends adminApi
|
||||
$data['quantity'] = $quantity;
|
||||
$data['remaining_number'] = $quantity;
|
||||
$data['createtime'] = time();
|
||||
$data['weight'] = $weight;
|
||||
$data['is_world_show'] = $is_world_show;
|
||||
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
@@ -165,7 +183,15 @@ class BlindBox extends adminApi
|
||||
*/
|
||||
public function blind_box_gifts(){
|
||||
$type = input('type', 2);
|
||||
$list = db::name("vs_gift")->where(['type'=>$type,'delete_time'=>0])->order('sort','asc')->select();
|
||||
$label = input('label', 0);
|
||||
$where['delete_time'] = 0;
|
||||
if($type){
|
||||
$where['type'] = $type;
|
||||
}
|
||||
if($label){
|
||||
$where['label'] = $label;
|
||||
}
|
||||
$list = db::name("vs_gift")->where($where)->order('sort','asc')->select();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['gid'] = $v['gid'];
|
||||
@@ -181,9 +207,12 @@ class BlindBox extends adminApi
|
||||
public function blind_box_edit(){
|
||||
$id = input('id', '');
|
||||
$quantity = input('quantity', 0);
|
||||
$is_world_show = input('is_world_show', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
if(empty($id)){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$weight = input('weight', 0);
|
||||
$gift_bag = db::name($this->table)->where('id',$id)->find();
|
||||
// if($gift_bag['remaining_number']>0){
|
||||
// return V(0,"该礼包已开售");
|
||||
@@ -191,6 +220,13 @@ class BlindBox extends adminApi
|
||||
$data = [];
|
||||
$data['quantity'] = $quantity;
|
||||
$data['remaining_number'] = $quantity;
|
||||
$data['is_world_show'] = $is_world_show;
|
||||
$data['weight'] = $weight;
|
||||
if(!empty($gift_id)){
|
||||
$gift = db::name('vs_gift')->where(['gid'=>$gift_id])->find();
|
||||
$data['foreign_id'] = $gift_id;
|
||||
$data['name'] = $gift['gift_name'];
|
||||
}
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
@@ -217,18 +253,113 @@ class BlindBox extends adminApi
|
||||
*/
|
||||
public function reset_set(){
|
||||
$gift_bag_id = input('gift_bag_id', 0);
|
||||
$room_id = input('room_id', 0);
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$gift_bag_detail = db::name($this->table)->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
// if(in_array($gift_bag_id,[10,11,12,13])){
|
||||
// $periods = 1;
|
||||
// $target_room_ids = [];
|
||||
// if(!empty($room_id)){
|
||||
// // 处理单个房间
|
||||
// $room_pan_detail = db::name('vs_room_pan')
|
||||
// ->where(['gift_bag_id'=>$gift_bag_id,'room_id'=>$room_id])
|
||||
// ->order('id desc')
|
||||
// ->find();
|
||||
//
|
||||
// if($room_pan_detail){
|
||||
// $periods = $room_pan_detail['periods'];
|
||||
// }
|
||||
// // 删除指定房间的数据
|
||||
// db::name('vs_room_pan')
|
||||
// ->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id])
|
||||
// ->delete();
|
||||
//
|
||||
// $target_room_ids = [$room_id];
|
||||
// }else{
|
||||
// // 处理所有房间
|
||||
// db::name('vs_room_pan')
|
||||
// ->where(['gift_bag_id'=>$gift_bag_id])
|
||||
// ->delete();
|
||||
//
|
||||
// $target_room_ids = db::name('vs_room')
|
||||
// ->where(['is_open_blind_box_turntable'=>1,'room_status'=>1])
|
||||
// ->column('id');
|
||||
// }
|
||||
// // 批量插入数据
|
||||
// $insert_data = [];
|
||||
// $update_data = [];
|
||||
// foreach ($gift_bag_detail as $v){
|
||||
// if(!empty($room_id)) {
|
||||
// // 单个房间更新或插入
|
||||
// $existing = db::name('vs_room_pan')
|
||||
// ->where([
|
||||
// 'room_id' => $room_id,
|
||||
// 'gift_bag_detail_id' => $v['id']
|
||||
// ])
|
||||
// ->find();
|
||||
//
|
||||
// if($existing) {
|
||||
// $update_data[] = [
|
||||
// 'id' => $existing['id'],
|
||||
// 'remaining_number' => $v['quantity'],
|
||||
// 'periods' => $periods
|
||||
// ];
|
||||
// } else {
|
||||
// $insert_data[] = [
|
||||
// 'room_id' => $room_id,
|
||||
// 'gift_bag_id' => $gift_bag_id,
|
||||
// 'gift_bag_detail_id' => $v['id'],
|
||||
// 'remaining_number' => $v['quantity'],
|
||||
// 'periods' => $periods,
|
||||
// 'createtime' => time(),
|
||||
// ];
|
||||
// }
|
||||
// } else {
|
||||
// // 多个房间批量插入
|
||||
// foreach ($target_room_ids as $mid){
|
||||
// $insert_data[] = [
|
||||
// 'room_id' => $mid,
|
||||
// 'gift_bag_id' => $gift_bag_id,
|
||||
// 'gift_bag_detail_id' => $v['id'],
|
||||
// 'remaining_number' => $v['quantity'],
|
||||
// 'periods' => $periods,
|
||||
// 'createtime' => time(),
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 执行批量插入
|
||||
// if(!empty($insert_data)) {
|
||||
// db::name('vs_room_pan')->insertAll($insert_data);
|
||||
// }
|
||||
// // 执行批量更新
|
||||
// if(!empty($update_data)) {
|
||||
// foreach($update_data as $update_item) {
|
||||
// db::name('vs_room_pan')
|
||||
// ->where(['id' => $update_item['id']])
|
||||
// ->update([
|
||||
// 'remaining_number' => $update_item['remaining_number'],
|
||||
// 'periods' => $update_item['periods']
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 更新盲盒详情的剩余数量
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
$bag_data = db::name($this->table)->where(['id'=>$v['id']])->update(['remaining_number'=>$v['quantity']]);
|
||||
}
|
||||
if($bag_data){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
// 清除缓存
|
||||
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,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -309,6 +440,8 @@ class BlindBox extends adminApi
|
||||
}
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
}else{
|
||||
$where['gift_bag_id'] = ['in',[7,8,9]];
|
||||
}
|
||||
if($periods){
|
||||
$where['periods'] = $periods;
|
||||
@@ -401,5 +534,383 @@ class BlindBox extends adminApi
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id,'status'=>1])->select();
|
||||
return V(1,"成功", $bag_list);
|
||||
}
|
||||
//--------------------------盲盒转盘与巡乐会-------------------------------------------------------
|
||||
|
||||
/*
|
||||
* 巡乐会规则详情
|
||||
*/
|
||||
public function xunlehui_rule_detail(){
|
||||
$gift_bag_id = 13;
|
||||
$gift_bag = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->find();
|
||||
$ext_data = json_decode($gift_bag['ext'],true);
|
||||
$ext_data['introd'] = stripcslashes($ext_data['introd']);
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>5,'status'=>1])->select();
|
||||
foreach ($bag_list as &$value) {
|
||||
$value['is_default'] = 0;
|
||||
if($value['id'] == $ext_data['inlet_bag_id']){
|
||||
$value['is_default'] = 1;
|
||||
}
|
||||
}
|
||||
$ext_data['bag_list'] = $bag_list;
|
||||
if($gift_bag){
|
||||
return V(1,"成功",$ext_data);
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 巡乐会规则设置
|
||||
*/
|
||||
public function xunlehui_set_rule(){
|
||||
$gift_bag_id = 13;
|
||||
$inlet_bag_id = input('inlet_bag_id', '');
|
||||
$waiting_start_num = input('waiting_start_num', '');
|
||||
$start_num = input('start_num', '');
|
||||
$selected_gift_id = input('selected_gift_id', '');
|
||||
$locking_gift_id = input('locking_gift_id', '');
|
||||
$give_homeowner_gift_id = input('give_homeowner_gift_id', '');
|
||||
$end_time = input('end_time', '');
|
||||
$tow_no_locking_time = input('tow_no_locking_time', '');
|
||||
$next_time = input('next_time', '');
|
||||
$introd =$_POST['introd']??"";
|
||||
$price = input('price', '');
|
||||
if(empty($inlet_bag_id)){
|
||||
return V(0,"请选择巡乐会绑定入口");
|
||||
}
|
||||
$ext =[
|
||||
'inlet_bag_id' => $inlet_bag_id,
|
||||
'gift_id' => $selected_gift_id,
|
||||
'xlh_box_price' => $price,
|
||||
'open_condition' => [
|
||||
'waiting_start_num' => $waiting_start_num,
|
||||
'start_num' => $start_num,
|
||||
],
|
||||
'locking_condition' => [
|
||||
'selected_gift_id' => $selected_gift_id,
|
||||
'locking_gift_id' => $locking_gift_id,
|
||||
'give_homeowner_gift_id' => $give_homeowner_gift_id,
|
||||
],
|
||||
'locking_time' => [
|
||||
'end_time' => $end_time,
|
||||
'tow_no_locking_time' => $tow_no_locking_time,
|
||||
'next_time' => $next_time,
|
||||
],
|
||||
'introd' => $introd,
|
||||
];
|
||||
$ext = json_encode($ext);
|
||||
$res = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->update(['ext'=>$ext]);
|
||||
if($res){
|
||||
//删除缓存
|
||||
$cacheKey = "xlh_config_13";
|
||||
cache::rm($cacheKey);
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 盲盒转盘统计
|
||||
*
|
||||
*/
|
||||
public function blind_box_turntable_lists(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_id = input('gift_id', '');
|
||||
$gift_name = input('gift_name', '');
|
||||
$gift_bag_id = input('gift_bag_id', 10);
|
||||
$room_id = input('room_id', '');
|
||||
if(empty($gift_bag_id)){
|
||||
return V(0,"请选择盲盒类型");
|
||||
}
|
||||
$room = db::name('vs_room')->where(['id'=>$room_id])->find();
|
||||
if(empty($room)){
|
||||
return V(0,"房间不存在");
|
||||
}
|
||||
if($room['is_open_blind_box_turntable'] !=1){
|
||||
return V(0,"该房间未开启盲盒转盘");
|
||||
}
|
||||
$bag_data = db::name("vs_gift_bag")->find($gift_bag_id);
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$bag_data['activities_id'],'status'=>1])->select();
|
||||
foreach ($bag_list as &$v) {
|
||||
$v['default'] = $gift_bag_id == $v['id'] ? 1 : 0;
|
||||
}
|
||||
$where=[];
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
if($gift_id!==''){
|
||||
$where['foreign_id'] =$gift_id;
|
||||
}
|
||||
if($gift_name!==''){
|
||||
$where['name'] = ['like', '%'.$gift_name.'%'];
|
||||
}
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$lists_data = db::name($this->table)->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
$periods =1;
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$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();
|
||||
$lists[$key]['base_image'] = $gift_data['base_image'];
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$room_pan = db::name('vs_room_pan')->where(['room_id'=>$room_id,'gift_bag_detail_id'=>$value['id']])->find();
|
||||
$lists[$key]['remaining_number'] = $room_pan['remaining_number'] ?? 0;
|
||||
$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]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$periods = $room_pan['periods']??1;
|
||||
}
|
||||
//统计
|
||||
$total_data = [];
|
||||
//每期总次数
|
||||
$total_count = db::name($this->table)->where(['gift_bag_id'=>$gift_bag_id])->sum('quantity');
|
||||
//每期总礼物价值
|
||||
$total_price_data = db::name($this->table)->alias('a')
|
||||
->field('a.quantity,b.gift_price,b.gift_price * a.quantity as total_price')
|
||||
->join('vs_gift b','a.foreign_id = b.gid')
|
||||
->where(['a.gift_bag_id'=>$gift_bag_id])
|
||||
->select();
|
||||
$total_price = array_sum(array_column($total_price_data,'total_price'));
|
||||
//每期总抽奖花费(支出)
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,name,ext')->where(['id'=>$gift_bag_id])->find();
|
||||
$ext = json_decode($bag_data['ext'],true);
|
||||
$c_gift_id = $ext['gift_id'];
|
||||
$c_gift_data = db::name('vs_gift')->where(['gid'=>$c_gift_id])->find();
|
||||
$gift_price = $c_gift_data['gift_price']??0;
|
||||
$total_cost = $total_count * $gift_price;
|
||||
//每期统计(收入/支出)
|
||||
if($total_cost==0 || $total_price==0){
|
||||
$profit_loss_ratio = 0;
|
||||
}else{
|
||||
$profit_loss_ratio =round(($total_price / $total_cost ),2);
|
||||
}
|
||||
//今天抽奖人数
|
||||
$today_count_user = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->group('user_id')
|
||||
->count();
|
||||
//今日抽奖总次数
|
||||
$today_total_count = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->count();
|
||||
//今日抽奖收入
|
||||
$today_total_price = db::name('vs_gift_bag_receive_log')
|
||||
->where(['gift_bag_id'=>$gift_bag_id,'createtime'=>['between',[strtotime(date('Y-m-d')),time()]]])
|
||||
->sum('bag_price');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'bag_list' => $bag_list,
|
||||
'total_data' => [
|
||||
'blind_box_turntable_periods' => $periods, //当前期数
|
||||
'remaining_number' => db::name('vs_room_pan')->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id])->sum('remaining_number')??'0',
|
||||
'total_count' => $total_count,
|
||||
'total_price' => $total_price,
|
||||
'total_cost' => $total_cost,
|
||||
'profit_loss_ratio' => $profit_loss_ratio,
|
||||
'today_count_user' => $today_count_user,
|
||||
'today_total_count' => $today_total_count,
|
||||
'today_total_price' => $today_total_price,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 盲盒转盘开奖记录
|
||||
*
|
||||
*/
|
||||
public function blind_box_turntable_open_record(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_id = input('gift_id', '');
|
||||
$user_id = input('user_id', '');
|
||||
$room_id = input('room_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$periods = input('periods', '');
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$where = [];
|
||||
if($room_id){
|
||||
$where['room_id'] = $room_id;
|
||||
}
|
||||
if($gift_id){
|
||||
$where['gift_id'] = $gift_id;
|
||||
}
|
||||
if($user_id){
|
||||
$user_id = db::name('user')->where('user_code', $user_id)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
}else{
|
||||
$where['gift_bag_id'] = ['in',[10,11,12]];
|
||||
}
|
||||
if($periods){
|
||||
$where['periods'] = $periods;
|
||||
}
|
||||
if($stime!==""){
|
||||
$where['createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if($etime!==""){
|
||||
$where['createtime'] = ['<=', strtotime($etime.'23:59:59')];
|
||||
}
|
||||
if($stime!=="" && $etime!==""){
|
||||
$where['createtime'] = ['between', [strtotime($stime), strtotime($etime.'23:59:59')]];
|
||||
}
|
||||
$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();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$user = db::name('user')->where('id',$value['user_id'])->find();
|
||||
$lists[$key]['user_name'] = "";
|
||||
if($user){
|
||||
$lists[$key]['user_name'] = $user['user_code'].'-'.$user['nickname'];
|
||||
}
|
||||
|
||||
$lists[$key]['gift_user_id'] = $value['gift_user_id'];
|
||||
$gift_user = db::name('user')->where('id',$value['gift_user_id'])->find();
|
||||
$lists[$key]['gift_user_name'] = "";
|
||||
if($gift_user){
|
||||
$lists[$key]['gift_user_name'] = $gift_user['user_code'].'-'.$gift_user['nickname'];
|
||||
}
|
||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||
$lists[$key]['periods'] = $value['periods'];
|
||||
$room = db::name('vs_room')->where('id',$value['room_id'])->find();
|
||||
$lists[$key]['room_name'] = "";
|
||||
if($room){
|
||||
$lists[$key]['room_name'] = $room['room_number']."-".$room['room_name'];
|
||||
}
|
||||
$lists[$key]['bag_price'] = $value['bag_price']*$value['num'];
|
||||
$lists[$key]['gift_id'] = $value['gift_id'];
|
||||
$lists[$key]['gift_name'] = db::name('vs_gift')->where('gid',$value['gift_id'])->value('gift_name');
|
||||
$lists[$key]['gift_price'] = $value['gift_price'];
|
||||
$lists[$key]['gift_num'] = $value['num'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
$all_lists_data = db::name('vs_gift_bag_receive_pan_log')->where($where)->order("id desc")->select();
|
||||
$total =0;
|
||||
$total_gift_money = 0;
|
||||
$total_money = 0;
|
||||
foreach ($all_lists_data as $key => $value) {
|
||||
$total += $value['num'];//总抽奖次数
|
||||
$total_gift_money += $value['gift_price'] * $value['num']; //总礼物价值(收入)
|
||||
$total_money += $value['bag_price'] * $value['num']; //总抽奖金额(支出)
|
||||
}
|
||||
//统计
|
||||
if($total_gift_money==0 || $total_money==0){
|
||||
$ratio = 0;
|
||||
}else{
|
||||
$ratio =round(($total_gift_money / $total_money),3);
|
||||
}
|
||||
//用户盈亏
|
||||
$profit_loss = $total_gift_money - $total_money;
|
||||
//平台盈亏
|
||||
$platform_profit_loss = $total_money - $total_gift_money;
|
||||
if($profit_loss==0 || $total_money==0){
|
||||
$profit_loss_ratio = 0;
|
||||
$platform_profit_loss_ratio = 0;
|
||||
}else{
|
||||
// 盈亏比
|
||||
$profit_loss_ratio = round(($profit_loss / $total_money),3);
|
||||
//平台盈亏比
|
||||
$platform_profit_loss_ratio = round(($platform_profit_loss / $total_money),3);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total_data' => [
|
||||
'total' => $total,
|
||||
'total_money' => $total_money,
|
||||
'total_gift_money' => $total_gift_money,
|
||||
'ratio' => $ratio,
|
||||
'profit_loss' => $profit_loss,
|
||||
'profit_loss_ratio' => $profit_loss_ratio,
|
||||
'platform_profit_loss' => $platform_profit_loss,
|
||||
'platform_profit_loss_ratio' => $platform_profit_loss_ratio,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
/*
|
||||
* 寻乐会锁定记录
|
||||
*
|
||||
*/
|
||||
public function xlh_lock_record(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$gift_id = input('gift_id', '');
|
||||
$user_id = input('user_id', '');
|
||||
$room_id = input('room_id', 0);
|
||||
$periods = input('periods', '');
|
||||
$where = [];
|
||||
if($room_id){
|
||||
$where['b.room_id'] = $room_id;
|
||||
}
|
||||
if($gift_id){
|
||||
$where['b.gift_id'] = $gift_id;
|
||||
}
|
||||
if($user_id){
|
||||
$user_id = db::name('user')->where('user_code', $user_id)->value('id');
|
||||
$where['b.user_id'] = $user_id;
|
||||
}
|
||||
if($periods){
|
||||
$where['b.periods'] = $periods;
|
||||
}
|
||||
|
||||
$count = db::name('vs_room_pan_xlh_log')->alias('a')
|
||||
->join('vs_room_pan_xlh b', 'a.xlh_id = b.id')
|
||||
->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')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->order("id desc")
|
||||
->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['periods'] = $value['periods'];
|
||||
$user = db::name('user')->field('user_code,nickname')->where('id',$value['user_id'])->find();
|
||||
$lists[$key]['user'] = $user['user_code']."-".$user['nickname'];
|
||||
//支付价格
|
||||
$lists[$key]['pay_price'] = $value['pay_price'];
|
||||
$gift = db::name('vs_gift')->field('gid,gift_name,gift_price')->where('gid',$value['locking_gift_id'])->find();
|
||||
$lists[$key]['gift_id'] = $value['locking_gift_id'];
|
||||
$lists[$key]['gift_name'] = $gift['gift_name']??"";
|
||||
$lists[$key]['gift_price'] = $gift['gift_price']??0;
|
||||
$lists[$key]['locking_num'] = $value['num'];
|
||||
$lists[$key]['is_send'] = $value['is_send'];
|
||||
$lists[$key]['is_send_str'] = $value['is_send']==1?"是":"否";
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
$room = db::name('vs_room')->where('id',$value['room_id'])->find();
|
||||
$lists[$key]['room_name'] = "";
|
||||
if($room){
|
||||
$lists[$key]['room_name'] = $room['room_number']."-".$room['room_name'];
|
||||
}
|
||||
}
|
||||
//今日锁定礼物数量
|
||||
$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');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'locking_num' => $locking_num
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,15 +51,18 @@ 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'] ? "SVGA" : "MP4";
|
||||
$return_list[$k]['file_type_str'] = $v['file_type']==1 ? "SVGA" : "MP4";
|
||||
$return_list[$k]['play_image'] = $v['play_image'];
|
||||
$return_list[$k]['show_status'] = $v['show_status'];
|
||||
$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,"该价格已存在");
|
||||
}
|
||||
@@ -327,6 +342,7 @@ class Decorate extends adminApi
|
||||
$type = input('type', '');
|
||||
$where = [];
|
||||
if($user_id!=""){
|
||||
$user_id = db::name('user')->where('user_code', $user_id)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
}
|
||||
if($did!=""){
|
||||
@@ -340,8 +356,9 @@ class Decorate extends adminApi
|
||||
$return_list = [];
|
||||
foreach ($lists as $k=>$v){
|
||||
$return_list[$k]['id'] = $v['udid'];
|
||||
$return_list[$k]['user_name'] = $v['user_id']."-".db::name('user')->where(['id'=>$v['user_id']])->value('nickname');
|
||||
$return_list[$k]['type'] = model('api/Decorate')->TypeArray[$v['type']];
|
||||
$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]['name'] = $v['special_num'];
|
||||
|
||||
@@ -373,18 +390,21 @@ class Decorate extends adminApi
|
||||
public function give_decorate(){
|
||||
$user_id = input('user_id', '');
|
||||
$decorate_id = input('decorate_id', '');
|
||||
$day = input('day', '');
|
||||
$user = db::name('user')->where(['id'=>$user_id])->find();
|
||||
$day = input('day', 0);
|
||||
$user = db::name('user')->where(['user_code'=>$user_id])->find();
|
||||
if(!$user){
|
||||
return V(0,"用户不存在");
|
||||
}
|
||||
$user_id = $user['id'];
|
||||
$decorate = db::name('vs_decorate')->where(['did'=>$decorate_id])->find();
|
||||
if(!$decorate){
|
||||
return V(0,"装扮不存在");
|
||||
}
|
||||
$decorate_price = db::name('vs_decorate_price')->where(['did'=>$decorate_id,'day'=>$day,'is_delete'=>1])->find();
|
||||
if(!$decorate_price){
|
||||
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){
|
||||
|
||||
@@ -44,7 +44,12 @@ class Gift extends adminApi
|
||||
}
|
||||
}
|
||||
if($type == 2){
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->order("sort asc,id desc")->select();
|
||||
$type_id = input('type_id', 0);
|
||||
$where['delete_time'] = 0;
|
||||
if(!empty($type_id)){
|
||||
$where['tid'] = $type_id;
|
||||
}
|
||||
$giftTypeData = db::name('vs_gift_label')->where($where)->order("sort asc,id desc")->select();
|
||||
foreach ($giftTypeData as $key => $value) {
|
||||
$giftType[$key]['id'] = $value['id'];
|
||||
$giftType[$key]['name'] = $value['name'];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
ini_set('memory_limit', '512M'); // 临时增加到512MB
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
|
||||
@@ -31,35 +31,47 @@ 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)){
|
||||
$where['createtime'] = ['between', [strtotime($start_time), strtotime($end_time.' 23:59:59')]];
|
||||
} elseif(!empty($start_time)){
|
||||
$where['createtime'] = ['>=', strtotime($start_time)];
|
||||
} elseif(!empty($end_time)){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
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)];
|
||||
}
|
||||
}
|
||||
//礼物总数
|
||||
$gift_num = db::name('vs_give_gift')->where($where)->sum('number');
|
||||
@@ -73,24 +85,29 @@ class GiveGift extends adminApi
|
||||
$room_owner_earning = 0;
|
||||
|
||||
// 获取所有送礼记录
|
||||
$list = db::name('vs_give_gift')->where($where)->order('id', 'desc')->select();
|
||||
$gift_ids = array_column($list, 'id');
|
||||
if (!empty($gift_ids)) {
|
||||
$lists = db::name('vs_give_gift')->where($where)->order('id', 'desc')->page($page, $page_limit)->select();
|
||||
$count = db::name('vs_give_gift')->where($where)->count();
|
||||
$earning_list = [];
|
||||
if(!empty($where)){
|
||||
$earning_list = db::name('vs_give_gift_ratio_log')
|
||||
->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')
|
||||
->where('give_gift_id', 'in', $gift_ids)
|
||||
->field('app_earning,gift_user_earning,room_owner_earning')
|
||||
->order('id', 'desc')
|
||||
->select();
|
||||
|
||||
// 计算总收益
|
||||
foreach ($earning_list as $earning) {
|
||||
$app_earning += $earning['app_earning'];
|
||||
$receive_earning += $earning['gift_user_earning'];
|
||||
$room_owner_earning += $earning['room_owner_earning'];
|
||||
}
|
||||
}
|
||||
$count = count($list);
|
||||
$lists = $this->array_pagination($list, $page, $page_limit);
|
||||
// 计算总收益
|
||||
foreach ($earning_list as $earning) {
|
||||
$app_earning += $earning['app_earning'];
|
||||
$receive_earning += $earning['gift_user_earning'];
|
||||
$room_owner_earning += $earning['room_owner_earning'];
|
||||
}
|
||||
|
||||
// 提取所有需要关联查询的ID
|
||||
$user_ids = array_merge(
|
||||
@@ -189,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,
|
||||
@@ -199,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);
|
||||
|
||||
@@ -84,11 +84,12 @@ class Guild extends adminApi
|
||||
//当日流水
|
||||
$list[$k]['today_money'] = 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]['user_id'] = $user['user_code']??"";
|
||||
$list[$k]['intro'] = $v['intro'];
|
||||
}
|
||||
// 数组按today_money 排序
|
||||
@@ -102,7 +103,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 +169,12 @@ class Guild extends adminApi
|
||||
return V(0, "靓号已使用");
|
||||
}
|
||||
}
|
||||
if(empty($request['guild_user_mobile'])){
|
||||
return V(0, "请填写会长手机号");
|
||||
}
|
||||
if(empty($request['password'])){
|
||||
return V(0, "请填写后台登录密码");
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data = [
|
||||
@@ -170,7 +191,13 @@ class Guild extends adminApi
|
||||
}
|
||||
//会长是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
$where = [
|
||||
'user_id' => $user_id,
|
||||
'delete_time' => 0
|
||||
];
|
||||
$where['apply_status'] = 2;//1待审核 2审核通过 3审核失败
|
||||
$where['type_id'] = ['<>',6];
|
||||
$room_info = db::name('vs_room')->where($where)->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
@@ -182,6 +209,15 @@ class Guild extends adminApi
|
||||
$insert_data['is_deacon'] = 1;
|
||||
$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();
|
||||
@@ -193,6 +229,25 @@ 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,
|
||||
'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) {
|
||||
@@ -242,10 +297,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'];
|
||||
}
|
||||
@@ -288,9 +343,9 @@ class Guild extends adminApi
|
||||
$res = model('Guild')->edit(['id'=>$id],['status'=>2,'delete_time'=>time()]);
|
||||
|
||||
if($res){
|
||||
db('vs_guild_user')->where(['guild_id'=>$id,'quit_type'=>0])->update(['quit_type'=>3,'quit_time'=>time()]);
|
||||
db('vs_guild_user')->where(['guild_id'=>$id,'quit_type'=>0])->update(['quit_type'=>3,'quit_time'=>time(),'delete_time'=>time()]);
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$id);
|
||||
model('api/Tencent')->delete_group('g'.$id);
|
||||
return V(1,"解散成功");
|
||||
}else{
|
||||
return V(0,"解散失败");
|
||||
@@ -336,9 +391,9 @@ class Guild extends adminApi
|
||||
$rum_lists[$k]['id']=$v['id'];
|
||||
$rum_lists[$k]['user_id']=$v['user_id'];
|
||||
$rum_lists[$k]['user_code']=model('api/Decorate')->user_decorate_detail($v['user_id'],6);
|
||||
$rum_lists[$k]['nickname']=$user_info['nickname'];
|
||||
$rum_lists[$k]['charm_level']=$user_info['charm_level'];
|
||||
$rum_lists[$k]['wealth_level']=$user_info['wealth_level'];
|
||||
$rum_lists[$k]['nickname']=$user_info['nickname']?? '';
|
||||
$rum_lists[$k]['charm_level']=$user_info['charm_level']??0;
|
||||
$rum_lists[$k]['wealth_level']=$user_info['wealth_level']??0;
|
||||
//用户流水
|
||||
$consumption_sql = db::name('vs_user_money_log')
|
||||
->whereIn('change_type',$coin_consumption_type_array)
|
||||
@@ -373,8 +428,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]];
|
||||
@@ -390,15 +445,44 @@ class Guild extends adminApi
|
||||
}
|
||||
$count = db::name($this->table_guild_user)->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id,'a.quit_type'=>['in',[0,3]]])->where($where)->count();
|
||||
->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,'a.quit_type'=>['in',[0,3]]])->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){
|
||||
$search_stime = $search_stime_str;
|
||||
$search_etime = $search_etime_str;
|
||||
if($search_stime!=""){
|
||||
if($search_stime!="" && $v['createtime'] < strtotime($search_stime)){
|
||||
$search_stime = $search_stime;
|
||||
}else{
|
||||
$search_stime = date('Y-m-d H:i:s',$v['createtime']) ;
|
||||
}
|
||||
}else{
|
||||
$search_stime = $search_stime;
|
||||
}
|
||||
if($search_etime!=""){
|
||||
if($v['quit_time']){
|
||||
if($search_etime!="" && $v['quit_time'] > strtotime($search_etime)){
|
||||
$search_etime = $search_etime;
|
||||
}else{
|
||||
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
|
||||
}
|
||||
}else{
|
||||
$search_etime = $search_etime;
|
||||
}
|
||||
}else{
|
||||
$search_etime = $search_etime;
|
||||
}
|
||||
|
||||
$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'];
|
||||
@@ -408,10 +492,18 @@ class Guild extends adminApi
|
||||
//房间流水
|
||||
$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'];
|
||||
}
|
||||
usort($rum_lists, function($a, $b) {
|
||||
return $b['consumption'] - $a['consumption'];
|
||||
});
|
||||
//分页
|
||||
$rum_lists = array_slice($rum_lists, ($page-1)*$page_limit, $page_limit);
|
||||
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'total_consumption' => $total_consumption,
|
||||
'count' => $count,
|
||||
'lists' => $rum_lists
|
||||
];
|
||||
@@ -617,12 +709,14 @@ class Guild extends adminApi
|
||||
$search_status_time = input('search_status_time', '');
|
||||
$search_end_time = input('search_end_time', '');
|
||||
$search_status = input('search_status', '');
|
||||
$where = ['b.delete_time'=>0];
|
||||
// $where = ['b.delete_time'=>0];
|
||||
$where = [];
|
||||
if($search_user_id){
|
||||
$where['b.user_id'] = $search_user_id;
|
||||
}
|
||||
if($search_guild_id){
|
||||
$where['a.guild_id'] = $search_guild_id;
|
||||
//$where['a.guild_id'] = $search_guild_id;
|
||||
$where['b.guild_special_id'] = $search_guild_id;
|
||||
}
|
||||
if($search_status_time){
|
||||
$where['a.start_time'] = ['>=', $search_status_time];
|
||||
@@ -640,7 +734,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();
|
||||
|
||||
@@ -54,6 +54,15 @@ class Index extends adminApi
|
||||
//总待付款笔数
|
||||
$return_data['all_wait_pay_num'] = db::name('vs_user_recharge')->where('pay_status',1)->count();
|
||||
|
||||
//周实时收入金额
|
||||
$return_data['week_money'] = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'week')->sum('money');
|
||||
//上周收入金额
|
||||
$return_data['last_week_money'] = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'last week')->sum('money');
|
||||
//月收入金额
|
||||
$return_data['month_money'] = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'month')->sum('money');
|
||||
//上月收入金额
|
||||
$return_data['last_month_money'] = db::name('vs_user_recharge')->where('pay_status',2)->whereTime('pay_time', 'last month')->sum('money');
|
||||
|
||||
//待办事项
|
||||
//房间审核数
|
||||
$return_data['room_audit_num'] = db::name('vs_room')->where('apply_status',1)->count();
|
||||
@@ -114,17 +123,27 @@ class Index extends adminApi
|
||||
$return_data['register_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->whereTime('createtime', 'today')->count();
|
||||
//充值会员数
|
||||
$return_data['recharge_count'] = db::name('vs_user_recharge')->where('pay_status',2)->group('user_id')->count();
|
||||
//充值会员百分比
|
||||
$return_data['recharge_count_percent'] = round(($return_data['recharge_count'] / $return_data['member_count']) * 100);
|
||||
//未充值会员数
|
||||
$return_data['no_recharge_count'] = $return_data['member_count'] - $return_data['recharge_count'];
|
||||
$return_data['no_recharge_count_percent'] = round(($return_data['no_recharge_count'] / $return_data['member_count']) * 100);
|
||||
//IOS用户数
|
||||
$return_data['ios_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->where('system', 'iOS')->count();
|
||||
$return_data['ios_count_percent'] = round(($return_data['ios_count'] / $return_data['member_count']) * 100);
|
||||
//安卓用户数
|
||||
$return_data['android_count'] = $return_data['member_count']-$return_data['ios_count'];
|
||||
$return_data['android_count_percent'] = round(($return_data['android_count'] / $return_data['member_count']) * 100);
|
||||
if(empty($return_data['member_count'])){
|
||||
$return_data['recharge_count_percent'] = 0;
|
||||
$return_data['no_recharge_count'] = 0;
|
||||
$return_data['no_recharge_count_percent'] = 0;
|
||||
$return_data['no_recharge_count'] = 0;
|
||||
$return_data['ios_count_percent'] = 0;
|
||||
$return_data['android_count'] = 0;
|
||||
$return_data['android_count_percent'] = 0;
|
||||
}else{
|
||||
//充值会员百分比
|
||||
$return_data['recharge_count_percent'] = round(($return_data['recharge_count'] / $return_data['member_count']) * 100);
|
||||
//未充值会员数
|
||||
$return_data['no_recharge_count'] = $return_data['member_count'] - $return_data['recharge_count'];
|
||||
$return_data['no_recharge_count_percent'] = round(($return_data['no_recharge_count'] / $return_data['member_count']) * 100);
|
||||
//IOS用户数
|
||||
$return_data['ios_count'] = db::name('user')->where('status', 1)->where('is_robot', 0)->where('system', 'iOS')->count();
|
||||
$return_data['ios_count_percent'] = round(($return_data['ios_count'] / $return_data['member_count']) * 100);
|
||||
//安卓用户数
|
||||
$return_data['android_count'] = $return_data['member_count']-$return_data['ios_count'];
|
||||
$return_data['android_count_percent'] = round(($return_data['android_count'] / $return_data['member_count']) * 100);
|
||||
}
|
||||
|
||||
//礼物打赏实时统计
|
||||
//一个月内的礼物打赏
|
||||
|
||||
@@ -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不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,18 +93,19 @@ class Level extends adminApi
|
||||
if(!$level_id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
//等级特权
|
||||
$decorate = db::name("vs_decorate")->where(['did' => $gift_id, 'delete_time' => 0])->find();
|
||||
if(empty($decorate)){
|
||||
return V(0,"请选择等级特权");
|
||||
}
|
||||
if($gift_id){
|
||||
if(!empty($gift_id)){
|
||||
//等级特权
|
||||
$decorate = db::name("vs_decorate")->where(['did' => $gift_id, 'delete_time' => 0])->find();
|
||||
if(empty($decorate)){
|
||||
return V(0,"请选择等级特权");
|
||||
}
|
||||
db::name('vs_wealth_level_rights')->insert([
|
||||
'level_id' => $level_id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
return V(1,"成功", ['id'=>$level]);
|
||||
}
|
||||
/*
|
||||
@@ -124,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();
|
||||
@@ -163,6 +164,8 @@ class Level extends adminApi
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
db::name('vs_wealth_level_rights')->where(['level_id'=>$id])->delete();
|
||||
}
|
||||
$result = db::name($this->table_wealth_level)->where(['id'=>$id])->update($level_data);
|
||||
if(!$result){
|
||||
|
||||
416
application/adminapi/controller/Nobility.php
Normal file
416
application/adminapi/controller/Nobility.php
Normal file
@@ -0,0 +1,416 @@
|
||||
<?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_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, "删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class Room extends adminApi
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_name = input('search_name', '');
|
||||
$where=[];
|
||||
$where['deletetime'] = 0;
|
||||
//标签名称
|
||||
if($search_name!==''){
|
||||
$where['label_name'] = ['like', '%'.$search_name.'%'];
|
||||
@@ -237,7 +237,7 @@ class Room extends adminApi
|
||||
if(!$type_data){
|
||||
return V(0,"房间类型不存在");
|
||||
}
|
||||
$result = db::name($this->table_room_type)->where(['id'=>$type_id])->delete();
|
||||
$result = db::name($this->table_room_type)->where(['id'=>$type_id])->update(['deletetime'=>time()]);
|
||||
if(!$result){
|
||||
return V(0,"删除失败");
|
||||
}
|
||||
@@ -386,6 +386,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', '');
|
||||
@@ -425,6 +431,12 @@ class Room extends adminApi
|
||||
$search_room_id = input('search_room_id', '');
|
||||
$search_user_id = input('search_user_id', '');
|
||||
$search_status = input('search_status', '');
|
||||
$type_id = input('type_id', '');
|
||||
$label_id = input('label_id', '');
|
||||
$is_hot = input('is_hot', '');
|
||||
$is_top = input('is_top', '');
|
||||
$is_recommend = input('is_recommend', '');
|
||||
|
||||
$where=[];
|
||||
//房间号
|
||||
if($search_room_id!==''){
|
||||
@@ -437,9 +449,25 @@ class Room extends adminApi
|
||||
if($search_status!==''){
|
||||
$where['room_status'] = $search_status;
|
||||
}
|
||||
if($type_id!==''){
|
||||
$where['type_id'] = $type_id;
|
||||
}else{
|
||||
$where['type_id'] = ['<>',6];
|
||||
}
|
||||
if($label_id!==''){
|
||||
$where['label_id'] = $label_id;
|
||||
}
|
||||
if($is_hot!==''){
|
||||
$where['is_hot'] = $is_hot;
|
||||
}
|
||||
if($is_top!==''){
|
||||
$where['is_top'] = $is_top;
|
||||
}
|
||||
if($is_recommend!==''){
|
||||
$where['is_recommend'] = $is_recommend;
|
||||
}
|
||||
//房间列表只展示 审核通过的房间
|
||||
$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 = [];
|
||||
@@ -468,6 +496,8 @@ class Room extends adminApi
|
||||
$lists[$key]['guild_name'] = !empty($guild) ? $guild['guild_name'] : "";
|
||||
$lists[$key]['room_status_str'] = model('Room')->room_status[$value['room_status']];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['is_robot_num'] = $value['robot_num']==0 ? 1 : 2;
|
||||
$lists[$key]['is_open_blind_box_turntable_str'] = $value['is_open_blind_box_turntable'] == 1 ? '是' : '否';
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
@@ -516,6 +546,7 @@ class Room extends adminApi
|
||||
$room_data['room_type_str'] = db::name('vs_room_type')->where(['id'=>$room_data['type_id']])->value('type_name');
|
||||
$room_data['liang'] = model('api/Decorate')->user_decorate_detail($room_data['id'],7);
|
||||
$room_data['owner'] = db::name('user')->where(['id'=>$room_data['user_id']])->value('nickname');
|
||||
$room_data['is_robot_num'] = $room_data['robot_num']==0 ? 2 : 1;
|
||||
$room_data['guild_name'] = '';
|
||||
$guild_id = db::name('vs_guild_user')->where('user_id',$room_data['user_id'])->value('guild_id');
|
||||
if($guild_id){
|
||||
@@ -653,8 +684,8 @@ class Room extends adminApi
|
||||
}
|
||||
elseif ($type == 3){
|
||||
//周流水
|
||||
//周一
|
||||
$begin_time = strtotime(date('Y-m-d 24:00:00',strtotime('-'.date('w').'days')));
|
||||
//本周一
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00', strtotime('this week')));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
@@ -818,11 +849,16 @@ class Room extends adminApi
|
||||
//在用户表里找 $robot_num 个机器人 进入到房间
|
||||
$user_list = db::name('user')->field('id')->where('is_robot',1)->limit($robot_num)->orderRaw('rand()')->select();
|
||||
if($user_list){
|
||||
if(count($user_list) != $robot_num){
|
||||
return V(0,"机器人数量不足");
|
||||
}
|
||||
foreach ($user_list as $v){
|
||||
model('api/Room')->join_room($v['id'],$room_id,$room_password);
|
||||
}
|
||||
}else{
|
||||
return V(0,"没有可用机器人");
|
||||
}
|
||||
}elseif ($is_robot_num == 2 && $robot_num == 0){
|
||||
}elseif ($is_robot_num == 2 || $robot_num == 0){
|
||||
$data['robot_num'] = 0;
|
||||
//查询在房间中的机器人 并退出
|
||||
$user_list = db::name('vs_room_visitor')->alias('a')->join('user b','a.user_id = b.id','left')
|
||||
@@ -836,7 +872,22 @@ class Room extends adminApi
|
||||
}
|
||||
}
|
||||
}
|
||||
$is_open_blind_box_turntable = input('is_open_blind_box_turntable', '');//是否开启盲盒转盘:0 否 1是
|
||||
if($is_open_blind_box_turntable !== ""){
|
||||
$data['is_open_blind_box_turntable'] = $is_open_blind_box_turntable;
|
||||
if($is_open_blind_box_turntable == 1){
|
||||
$room_data = db::name('vs_room')->find($room_id);
|
||||
if($room_data['is_open_blind_box_turntable'] == 0){
|
||||
model('Room')->bindPan($room_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//排序
|
||||
$sort = input('sort', '');//排序 越大越靠前
|
||||
if($sort !== ""){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
@@ -909,9 +960,22 @@ class Room extends adminApi
|
||||
if($status){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
$bg_url = db::name('vs_room_background')->where('id',$id)->value('image_url');
|
||||
|
||||
$res = db::name('vs_room_background')->where('id',$id)->update($data);
|
||||
if($res){
|
||||
if($bg_url != $image_url){
|
||||
//查询使用默认背景的房间
|
||||
$room_list = db::name('vs_room')->field('id,room_background')->where(['room_status' => ['<>',3]])->select();
|
||||
if($room_list){
|
||||
foreach ($room_list as $v){
|
||||
//判断是否使用默认背景,room_background 字段值是否是以 get_system_config_value('web_site') 开头
|
||||
if(strpos($v['room_background'],get_system_config_value('web_site')) !== FALSE){
|
||||
db::name('vs_room')->where('id',$v['id'])->update(['room_background' => $image_url]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
@@ -962,6 +1026,10 @@ class Room extends adminApi
|
||||
$search_room_number = input('search_room_number', '');
|
||||
$search_onwer_number = input('search_onwer_number', '');
|
||||
$room_status = input('room_status', '');
|
||||
//开始 时间
|
||||
$start_time = input('start_time', '');
|
||||
//结束 时间
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
if($search_room_number!==''){
|
||||
$where['room_number'] = $search_room_number;
|
||||
@@ -972,12 +1040,36 @@ class Room extends adminApi
|
||||
if($room_status!==''){
|
||||
$where['room_status'] = $room_status;
|
||||
}
|
||||
|
||||
// 检查并转换时间格式为时间戳
|
||||
if($start_time !== '' && $end_time !== ''){
|
||||
// 同时有开始和结束时间
|
||||
$startTime = strtotime($start_time);
|
||||
$endTime = strtotime($end_time);
|
||||
if($startTime !== false && $endTime !== false){
|
||||
$where['createtime'] = ['between', [$startTime, $endTime]];
|
||||
}
|
||||
}elseif($start_time !== ''){
|
||||
// 只有开始时间
|
||||
$startTime = strtotime($start_time);
|
||||
if($startTime !== false){
|
||||
$where['createtime'] = ['>=', $startTime];
|
||||
}
|
||||
}elseif($end_time !== ''){
|
||||
// 只有结束时间
|
||||
$endTime = strtotime($end_time);
|
||||
if($endTime !== false){
|
||||
$where['createtime'] = ['<=', $endTime];
|
||||
}
|
||||
}
|
||||
|
||||
$where['type_id'] = 6;
|
||||
$count = db::name('vs_room')->where($where)->count();
|
||||
$lists = db::name('vs_room')->field('id,room_name,room_cover,room_number,user_id,room_status,createtime')
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->page($page, $page_limit)->select();
|
||||
|
||||
foreach ($lists as &$value) {
|
||||
$guild = model('Guild')->getGuildByUserId($value['user_id']);
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
@@ -988,7 +1080,27 @@ class Room extends adminApi
|
||||
$value['room_code'] = model('api/Decorate')->user_decorate_detail($value['id'], 7);
|
||||
//房间状态1正常2封禁3关闭
|
||||
$value['room_status_str'] = $value['room_status'] ==1 ? "正常" : ($value['room_status'] ==2 ? "封禁" : "关闭");
|
||||
|
||||
$cpRoom = db::name('vs_room_cp_movie')->where('room_id',$value['id'])->find();
|
||||
if($cpRoom){
|
||||
if($cpRoom['user_id'] == $value['user_id']){
|
||||
$value['cp_nickname'] = db::name('user')->where('id', $cpRoom['user_id1'])->value('nickname');
|
||||
$value['cp_user_id'] = db::name('user')->where('id', $cpRoom['user_id1'])->value('user_code');
|
||||
}
|
||||
if($cpRoom['user_id1'] == $value['user_id']){
|
||||
$value['cp_nickname'] = db::name('user')->where('id', $cpRoom['user_id'])->value('nickname');
|
||||
$value['cp_user_id'] = db::name('user')->where('id', $cpRoom['user_id'])->value('user_code');
|
||||
}
|
||||
}
|
||||
|
||||
// 流水计算也应使用相同的时间范围
|
||||
$liushuiWhere = ['from_id' => $value['id']];
|
||||
if(isset($where['createtime'])){
|
||||
$liushuiWhere['createtime'] = $where['createtime'];
|
||||
}
|
||||
$value['liushui'] = db::name('vs_give_gift')->where($liushuiWhere)->sum('total_price') * get_system_config_value('coin_charm_exp');
|
||||
}
|
||||
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -998,6 +1110,7 @@ class Room extends adminApi
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
//Cp电影房封禁
|
||||
public function cp_movie_room_forbid()
|
||||
{
|
||||
@@ -1211,7 +1324,7 @@ class Room extends adminApi
|
||||
if($apply_status!==''){
|
||||
$where['apply_status'] = $apply_status;
|
||||
}else{
|
||||
$where['apply_status'] = ['<>',2];
|
||||
$where['apply_status'] = 1;
|
||||
}
|
||||
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
@@ -1238,6 +1351,7 @@ class Room extends adminApi
|
||||
//房间审核
|
||||
public function room_audit(){
|
||||
$id = input('id', '');
|
||||
$remark = input('remark', '');
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
@@ -1245,10 +1359,40 @@ class Room extends adminApi
|
||||
if($apply_status == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = db::name('vs_room')->where(['id'=>$id])->update(['apply_status'=>$apply_status]);
|
||||
$room_data = db::name('vs_room')->where(['id'=>$id])->find();
|
||||
if(!$room_data){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$result = db::name('vs_room')->where(['id'=>$id])->update([
|
||||
'apply_status'=>$apply_status,
|
||||
'is_open_blind_box_turntable'=>1,
|
||||
'updatetime'=>time(),
|
||||
]);
|
||||
if(!$result){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
|
||||
//发系统信息
|
||||
if($apply_status ==2){
|
||||
$deal_content = '审核通过';
|
||||
}elseif($apply_status ==3){
|
||||
$deal_content = '审核未通过';
|
||||
}
|
||||
if(!empty($remark)){
|
||||
$deal_content .= ',原因:'.$remark;
|
||||
}
|
||||
db::name('system_message')->insert([
|
||||
'title' => '房间审核结果',
|
||||
'content' => '您创建的房间'.$room_data['room_name'].$deal_content,
|
||||
'type' => 1,
|
||||
'admin_id' => Session::get('admin_id'),
|
||||
'receiving_id' => $room_data['user_id'],
|
||||
'createtime' => time(),
|
||||
]);
|
||||
|
||||
//房间绑定盘
|
||||
model('Room')->bindPan($id);
|
||||
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
@@ -1404,10 +1548,10 @@ class Room extends adminApi
|
||||
$where['createtime'] = ['>=',strtotime($stime)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$where['createtime'] = ['<=',strtotime($etime.' 23:59:59')];
|
||||
$where['createtime'] = ['<=',strtotime($etime)];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['createtime'] = ['between',[strtotime($stime),strtotime($etime.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||
}
|
||||
$room_log_lists = db::name($this->table_room_log)->where($where)->order('id desc')->page($page, $page_limit)->select();
|
||||
$count = db::name($this->table_room_log)->where($where)->count();
|
||||
@@ -1575,4 +1719,183 @@ class Room extends adminApi
|
||||
return V(1,"成功", $result);
|
||||
}
|
||||
|
||||
// 房间红包列表
|
||||
public function room_redpacket_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$room_id = input('room_id', '');
|
||||
//红包状态
|
||||
$status = input('status', '');
|
||||
//发红包的时间
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$where = [];
|
||||
if($room_id){
|
||||
$where['room_id'] = $room_id;
|
||||
}
|
||||
if($status){
|
||||
$where['status'] = $status;
|
||||
}
|
||||
if($stime){
|
||||
$where['createtime'] = ['>=',strtotime($stime)];
|
||||
}
|
||||
if($etime){
|
||||
$where['createtime'] = ['<=',strtotime($etime)];
|
||||
}
|
||||
$count = db::name("redpacket")->where($where)->count();
|
||||
$room_redpacket_lists = db::name("redpacket")->where($where)->page($page, $page_limit)->order('id desc')->select();
|
||||
//循环数据 获取发红的昵称和头像 时间格式化 状态:0=未开始,1=进行中,2=已结束,3=已退回' 币种(coin_type):1=金币,2=钻石',红包类型(type):1=普通红包,2=口令红包'
|
||||
//多选条件(逗号分隔存值)(conditions) 0=无,1=收藏,2=在麦上
|
||||
if($room_redpacket_lists){
|
||||
foreach ($room_redpacket_lists as $key => $value){
|
||||
$room_redpacket_lists[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
$room_redpacket_lists[$key]['avatar'] = db::name('user')->where(['id'=>$value['user_id']])->value('avatar');
|
||||
$room_redpacket_lists[$key]['user_code'] = db::name('user')->where(['id'=>$value['user_id']])->value('user_code');
|
||||
$room_redpacket_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$room_redpacket_lists[$key]['status_text'] = $value['status'] == 0 ? '未开始' : ($value['status'] == 1 ? '进行中' : ($value['status'] == 2 ? '已结束' : '已退回'));
|
||||
$room_redpacket_lists[$key]['coin_type_text'] = $value['coin_type'] == 1 ? '金币' : ($value['coin_type'] == 2 ? '钻石' : '未知');
|
||||
$room_redpacket_lists[$key]['type_text'] = $value['type'] == 1 ? '普通红包' : ($value['type'] == 2 ? '口令红包' : '未知');
|
||||
|
||||
// 多选条件处理:0=无(不能和其他条件共存),1=收藏,2=在麦上
|
||||
// 可以同时存在,也可以单独存在,同时存在时用逗号分隔
|
||||
$conditions = explode(',',$value['conditions']);
|
||||
// 过滤掉空值元素
|
||||
$conditions = array_filter($conditions, function($item) {
|
||||
return $item !== '' && $item !== null;
|
||||
});
|
||||
// 去除重复的条件
|
||||
$conditions = array_unique($conditions);
|
||||
// 重新索引数组,确保索引连续
|
||||
$conditions = array_values($conditions);
|
||||
|
||||
// 特殊处理:如果包含条件0(无条件),则只保留这一项
|
||||
if (in_array('0', $conditions)) {
|
||||
$room_redpacket_lists[$key]['conditions'] = ['无条件'];
|
||||
} else {
|
||||
// 将数字条件转换为对应的中文描述
|
||||
$conditions_text = array_map(function($item){
|
||||
// 0=无条件,1=收藏,2=在麦上
|
||||
switch($item) {
|
||||
case '0':
|
||||
return '无条件';
|
||||
case '1':
|
||||
return '收藏';
|
||||
case '2':
|
||||
return '在麦上';
|
||||
default:
|
||||
return '未知';
|
||||
}
|
||||
}, $conditions);
|
||||
$room_redpacket_lists[$key]['conditions'] = $conditions_text;
|
||||
}
|
||||
//房间名称
|
||||
$room_redpacket_lists[$key]['room_name'] = db::name('vs_room')->where(['id'=>$value['room_id']])->value('room_name');
|
||||
}
|
||||
}
|
||||
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $room_redpacket_lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
// 获取房间红包详情
|
||||
public function room_redpacket_detail(){
|
||||
// 红包ID
|
||||
$redpacket_id = input('redpacket_id', '');
|
||||
if(empty($redpacket_id)){
|
||||
return V(0, "红包ID不能为空");
|
||||
}
|
||||
|
||||
// 获取红包基本信息
|
||||
$redpacket_info = db::name("redpacket")->where(['id'=>$redpacket_id])->find();
|
||||
if(!$redpacket_info){
|
||||
return V(0, "红包不存在");
|
||||
}
|
||||
|
||||
// 获取发红包用户信息
|
||||
$redpacket_info['nickname'] = db::name('user')->where(['id'=>$redpacket_info['user_id']])->value('nickname');
|
||||
$redpacket_info['avatar'] = db::name('user')->where(['id'=>$redpacket_info['user_id']])->value('avatar');
|
||||
$redpacket_info['user_code'] = db::name('user')->where(['id'=>$redpacket_info['user_id']])->value('user_code');
|
||||
$redpacket_info['createtime_text'] = date('Y-m-d H:i:s', $redpacket_info['createtime']);
|
||||
$redpacket_info['start_time_text'] = date('Y-m-d H:i:s', $redpacket_info['start_time']);
|
||||
$redpacket_info['end_time_text'] = date('Y-m-d H:i:s', $redpacket_info['end_time']);
|
||||
//房间名称
|
||||
$redpacket_info['room_name'] = db::name('vs_room')->where(['id'=>$redpacket_info['room_id']])->value('room_name');
|
||||
|
||||
// 红包状态文字描述
|
||||
$status_map = [
|
||||
0 => '未开始',
|
||||
1 => '进行中',
|
||||
2 => '已结束',
|
||||
3 => '已退回'
|
||||
];
|
||||
$redpacket_info['status_text'] = $status_map[$redpacket_info['status']] ?? '未知';
|
||||
|
||||
// 币种文字描述
|
||||
$coin_type_map = [
|
||||
1 => '金币',
|
||||
2 => '钻石'
|
||||
];
|
||||
$redpacket_info['coin_type_text'] = $coin_type_map[$redpacket_info['coin_type']] ?? '未知';
|
||||
|
||||
// 红包类型文字描述
|
||||
$type_map = [
|
||||
1 => '普通红包',
|
||||
2 => '口令红包'
|
||||
];
|
||||
$redpacket_info['type_text'] = $type_map[$redpacket_info['type']] ?? '未知';
|
||||
|
||||
// 领取条件处理
|
||||
$conditions = explode(',',$redpacket_info['conditions']);
|
||||
$conditions = array_filter($conditions, function($item) {
|
||||
return $item !== '' && $item !== null;
|
||||
});
|
||||
$conditions = array_unique($conditions);
|
||||
$conditions = array_values($conditions);
|
||||
|
||||
// 特殊处理:如果包含条件0(无条件),则只保留这一项
|
||||
if (in_array('0', $conditions)) {
|
||||
$redpacket_info['conditions_text'] = ['无条件'];
|
||||
} else {
|
||||
// 将数字条件转换为对应的中文描述
|
||||
$conditions_text = array_map(function($item){
|
||||
switch($item) {
|
||||
case '0':
|
||||
return '无条件';
|
||||
case '1':
|
||||
return '收藏';
|
||||
case '2':
|
||||
return '在麦上';
|
||||
default:
|
||||
return '未知';
|
||||
}
|
||||
}, $conditions);
|
||||
$redpacket_info['conditions_text'] = $conditions_text;
|
||||
}
|
||||
|
||||
// 领取详情 redpacket_record 表里面的数据
|
||||
// 外键redpacket_id redpacket表的ID,user_id 外键user表的ID amount 抢到的金额 createtime抢红包的时间
|
||||
// 红包领取详情 谁在什么时候 抢红包 抢了多少钱
|
||||
$redpacket_record_lists = db::name("redpacket_record")->where(['redpacket_id'=>$redpacket_id])->order('createtime asc')->select();
|
||||
if($redpacket_record_lists){
|
||||
foreach ($redpacket_record_lists as $key => $value){
|
||||
$redpacket_record_lists[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
$redpacket_record_lists[$key]['avatar'] = db::name('user')->where(['id'=>$value['user_id']])->value('avatar');
|
||||
$redpacket_record_lists[$key]['user_code'] = db::name('user')->where(['id'=>$value['user_id']])->value('user_code');
|
||||
$redpacket_record_lists[$key]['createtime_text'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
}
|
||||
|
||||
$return_data = [
|
||||
'redpacket_info' => $redpacket_info,
|
||||
'record_lists' => $redpacket_record_lists
|
||||
];
|
||||
|
||||
return V(1, "成功", $return_data);
|
||||
}
|
||||
|
||||
}
|
||||
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, '删除失败');
|
||||
}
|
||||
}
|
||||
371
application/adminapi/controller/RoomHourRanking.php
Normal file
371
application/adminapi/controller/RoomHourRanking.php
Normal file
@@ -0,0 +1,371 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class RoomHourRanking
|
||||
{
|
||||
public static function withdraw_status (){
|
||||
return [
|
||||
// [25 => '全时段'],
|
||||
[0 => '00:00-01:00'],
|
||||
[1 => '01:00-02:00'],
|
||||
[2 => '02:00-03:00'],
|
||||
[3 => '03:00-04:00'],
|
||||
[4 => '04:00-05:00'],
|
||||
[5 => '05:00-06:00'],
|
||||
[6 => '06:00-07:00'],
|
||||
[7 => '07:00-08:00'],
|
||||
[8 => '08:00-09:00'],
|
||||
[9 => '09:00-10:00'],
|
||||
[10 => '10:00-11:00'],
|
||||
[11 => '11:00-12:00'],
|
||||
[12 => '12:00-13:00'],
|
||||
[13 => '13:00-14:00'],
|
||||
[14 => '14:00-15:00'],
|
||||
[15 => '15:00-16:00'],
|
||||
[16 => '16:00-17:00'],
|
||||
[17 => '17:00-18:00'],
|
||||
[18 => '18:00-19:00'],
|
||||
[19 => '19:00-20:00'],
|
||||
[20 => '20:00-21:00'],
|
||||
[21 => '21:00-22:00'],
|
||||
[22 => '22:00-23:00'],
|
||||
[23 => '23:00-00:00'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
//房间小时榜列表
|
||||
public function room_hour_ranking()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$search_ranking = input('search_ranking', '');
|
||||
$search_stime = input('search_stime', '');
|
||||
$search_etime = input('search_etime', '');
|
||||
$where = [];
|
||||
if ($search_ranking) {
|
||||
$where[] = ['room_name', 'like', '%' . $search_ranking . '%'];
|
||||
}
|
||||
if ($search_stime) {
|
||||
$where[] = ['stime', '>=', $search_stime];
|
||||
}
|
||||
if ($search_etime) {
|
||||
$where[] = ['etime', '<=', $search_etime];
|
||||
}
|
||||
$count = db::name('vs_hour_ranking')->where($where)->count();
|
||||
$list = db::name('vs_hour_ranking')->where($where)->page($page, $page_limit)->order('id desc')->select();
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['room_name'] = db::name('vs_room')->where(['id'=>$v['room_id']])->value('room_name');
|
||||
$v['user_id'] = db::name('vs_room')->where(['id'=>$v['room_id']])->value('user_id');
|
||||
if($v['user_id']){
|
||||
$v['nickname'] = db::name('user')->where(['id'=>$v['user_id']])->value('nickname');
|
||||
}
|
||||
$v['stime'] = date('Y-m-d H:i', $v['stime']);
|
||||
$v['etime'] = date('Y-m-d H:i', $v['etime']);
|
||||
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//房间小时榜配置
|
||||
public function room_hour_ranking_config()
|
||||
{
|
||||
$list = db::name('vs_hour_ranking_config')->where('id', '1')->find();
|
||||
if($list){
|
||||
//open_time 字段转化为2025-09-30 07:00 的格式
|
||||
$list['open_time'] = $list['open_time'] ? date('Y-m-d H:i', $list['open_time']) : 0;
|
||||
}
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
//房间小时榜配置修改
|
||||
public function room_hour_ranking_config_edit()
|
||||
{
|
||||
$id = input('id');
|
||||
$data['is_open_red_pack'] = 0;//暂时不开启
|
||||
$data['is_public_server'] = input('is_public_server');
|
||||
$data['broadcast_times'] = input('broadcast_times');
|
||||
$data['is_open_xlh'] = input('is_open_xlh');
|
||||
$data['min_price'] = input('min_price');
|
||||
$open_time = input('open_time');
|
||||
$data['open_time'] = $open_time ? strtotime($open_time) : 0;
|
||||
$data['createtime'] = time();
|
||||
$data['updatetime'] = time();
|
||||
|
||||
$timeSlots = json_decode(input('timeJson'), true);
|
||||
|
||||
$timePeriods = $this->withdraw_status();
|
||||
|
||||
// 构建正确的时间映射关系
|
||||
$timeMap = [];
|
||||
foreach($timePeriods as $period) {
|
||||
foreach($period as $key => $value) {
|
||||
$timeMap[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
//$timeMap 里面 键值互换
|
||||
$timeMap = array_flip($timeMap);
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
if($timeSlots){
|
||||
$insertData = [];
|
||||
foreach ($timeSlots as $timeSlot) {
|
||||
// $timeRange = ;
|
||||
$timeRange = $timeMap[$timeSlot['time']] ?? '99';
|
||||
|
||||
foreach ($timeSlot['reward'] as $rewardItem) {
|
||||
$hasReward = !empty($rewardItem['content']);
|
||||
|
||||
if ($hasReward) {
|
||||
// 有奖励内容:为每个奖励内容创建一条记录
|
||||
foreach ($rewardItem['content'] as $rewardContent) {
|
||||
if($rewardContent['type'] == 0){
|
||||
$coin = $rewardContent['value'];
|
||||
$gift_id = 0;
|
||||
$gift_name = '';
|
||||
}else{
|
||||
$coin = 0;
|
||||
$gift_id = $rewardContent['value'];
|
||||
$gift_name = $rewardContent['name'];
|
||||
}
|
||||
$insertData[] = [
|
||||
'time_id' => $timeRange,
|
||||
'ranking' => $rewardItem['index'],
|
||||
// 'rank_name' => $rewardItem['name'],
|
||||
'gift_type' => $rewardContent['type'],
|
||||
'gift_id' => $gift_id,
|
||||
'coin' => $coin,
|
||||
'name' => $gift_name,
|
||||
'createtime' => time()
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// 无奖励内容:插入一条空奖励记录
|
||||
$insertData[] = [
|
||||
'time_id' => $timeRange,
|
||||
'ranking' => $rewardItem['index'],
|
||||
// 'rank_name' => $rewardItem['name'],
|
||||
'gift_type' => 0,
|
||||
'gift_id' => 0,
|
||||
'coin' => 0,
|
||||
'name' => '',
|
||||
'createtime' => time(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量插入
|
||||
if (!empty($insertData)) {
|
||||
$del = db::name('vs_hour_ranking_gift_config')->where('id','>',0)->delete();
|
||||
$ins = db::name('vs_hour_ranking_gift_config')->insertAll($insertData);
|
||||
}else{
|
||||
$ins = false;
|
||||
$del = false;
|
||||
}
|
||||
|
||||
}else{
|
||||
$del = true;
|
||||
$ins = true;
|
||||
}
|
||||
|
||||
// $res = db::name('vs_hour_ranking_config')->where('id', $id)->update($data);
|
||||
$res = db::name('vs_hour_ranking_config')->where('id', $id)->update($data);
|
||||
// if ($del && $ins && $res) {
|
||||
if ($ins) {
|
||||
db::commit();
|
||||
return V(1, "成功");
|
||||
} else {
|
||||
db::rollback();
|
||||
return V(0, "失败");
|
||||
}
|
||||
}
|
||||
|
||||
//时间段对应关系
|
||||
public function time_period_correspondence()
|
||||
{
|
||||
$list = $this->withdraw_status();
|
||||
$timePeriods = $this->withdraw_status();
|
||||
$timeMap = [];
|
||||
foreach($timePeriods as $period) {
|
||||
foreach($period as $key => $value) {
|
||||
$timeMap[$key] = $value;
|
||||
}
|
||||
}
|
||||
return V(1,"成功", $timeMap);
|
||||
}
|
||||
|
||||
|
||||
//添加核心配置
|
||||
public function add_core_config()
|
||||
{
|
||||
$data['is_public_server'] = input('is_public_server');
|
||||
$data['createtime'] = time();
|
||||
$data['updatetime'] = time();
|
||||
|
||||
|
||||
$res = db::name('vs_hour_ranking_config')->insert($data);
|
||||
}
|
||||
|
||||
//核心配置列表
|
||||
public function core_config_list()
|
||||
{
|
||||
$timePeriods = $this->withdraw_status();
|
||||
|
||||
// 构建正确的时间映射关系
|
||||
$timeMap = [];
|
||||
foreach($timePeriods as $period) {
|
||||
foreach($period as $key => $value) {
|
||||
$timeMap[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// 先按时间段和排名索引分组查询
|
||||
$timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true)
|
||||
->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')
|
||||
->select();
|
||||
|
||||
$rewardMap = [];
|
||||
foreach ($rewards as $reward) {
|
||||
$rankIndex = $reward['ranking'];
|
||||
|
||||
if (!isset($rewardMap[$rankIndex])) {
|
||||
$rewardMap[$rankIndex] = [
|
||||
'index' => $rankIndex,
|
||||
// 'name' => $reward['rank_name'],
|
||||
'content' => []
|
||||
];
|
||||
}
|
||||
|
||||
// 添加奖励内容到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'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 按index排序
|
||||
ksort($rewardMap);
|
||||
|
||||
$result[] = [
|
||||
'time' => $timeMap[$timeRange],
|
||||
'reward' => array_values($rewardMap)
|
||||
];
|
||||
}
|
||||
|
||||
return V(1, "成功", $result);
|
||||
|
||||
}
|
||||
|
||||
// public function core_config_lists()
|
||||
// {
|
||||
// $list = db::name('vs_hour_ranking_gift_config')->select();
|
||||
// $data = [];
|
||||
//
|
||||
// // 按 time_id 和 ranking 重组数据
|
||||
// $reorganizedData = [];
|
||||
// $timePeriods = $this->withdraw_status();
|
||||
//
|
||||
// // 构建正确的时间映射关系
|
||||
// $timeMap = [];
|
||||
// foreach($timePeriods as $period) {
|
||||
// foreach($period as $key => $value) {
|
||||
// $timeMap[$key] = $value;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// foreach ($list as $item) {
|
||||
//// $timeId = $item['time_id'];
|
||||
// $timeId = $timeMap[$item['time_id']] ?? '未知时间段';
|
||||
// $ranking = $item['ranking'];
|
||||
//
|
||||
// $gift_name = '';
|
||||
// if (!isset($reorganizedData[$timeId])) {
|
||||
// $reorganizedData[$timeId] = [];
|
||||
// }
|
||||
// if (!isset($reorganizedData[$timeId][$ranking])) {
|
||||
// $reorganizedData[$timeId][$ranking] = [];
|
||||
// }
|
||||
// if($item['gift_id']){
|
||||
// if($item['gift_type'] == 2){
|
||||
// $gift_name = db::name('vs_gift')->where(['gid'=>$item['gift_id']])->value('gift_name');
|
||||
// }
|
||||
// if($item['gift_type'] == 3 || $item['gift_type'] == 4){
|
||||
// $gift_name = db::name('vs_decorate')->where(['did'=>$item['gift_id']])->value('title');
|
||||
// }
|
||||
//
|
||||
// }else{
|
||||
// $gift_name = '';
|
||||
// }
|
||||
// $reorganizedData[$timeId][$ranking][] = [
|
||||
// 'gift_type' => $item['gift_type'],
|
||||
// 'gift_id' => $item['gift_id'],
|
||||
// 'gift_name' => $gift_name,
|
||||
// 'coin' => $item['coin']
|
||||
// ];
|
||||
// }
|
||||
//
|
||||
// // 输出重组后的数据
|
||||
// print_r($reorganizedData);
|
||||
// return V(1, "成功", $data);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
254
application/adminapi/controller/SingerSong.php
Normal file
254
application/adminapi/controller/SingerSong.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?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=[];
|
||||
//搜索信息有值且是纯数字
|
||||
if(is_numeric($search)){
|
||||
$where['ss.user_id'] = $search;
|
||||
$wheres['user_id'] = $search;
|
||||
}
|
||||
if($search && !is_numeric($search)){
|
||||
$where['u.nickname'] = ['like', '%'.$search.'%'];;
|
||||
}
|
||||
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;
|
||||
}else{
|
||||
$where = [];
|
||||
$wheres = [];
|
||||
}
|
||||
|
||||
$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)
|
||||
->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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -37,10 +37,10 @@ class Statistical extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
|
||||
$where['pay_status'] = 2;//1待支付,2已支付
|
||||
@@ -112,10 +112,10 @@ class Statistical extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$count = db::name('vs_give_gift')
|
||||
->where($where)
|
||||
@@ -177,10 +177,10 @@ class Statistical extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
@@ -239,10 +239,10 @@ class Statistical extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
//不为空
|
||||
$where['from'] = 2;
|
||||
@@ -259,9 +259,14 @@ class Statistical extends adminApi
|
||||
->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$room = db::name('vs_room')->where('id', $value['from_id'])->find();
|
||||
if($room){
|
||||
$lists[$key]['room_name'] = $room['room_name'].'-'.$room['room_number'];
|
||||
$lists[$key]['room_number'] = $room['room_number'];
|
||||
}else{
|
||||
$lists[$key]['room_name'] = "--";
|
||||
$lists[$key]['room_number'] = "--";
|
||||
}
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['room_name'] = $room['room_name'].'-'.$room['room_number'];
|
||||
$lists[$key]['room_number'] = $room['room_number'];
|
||||
$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');
|
||||
@@ -302,10 +307,10 @@ class Statistical extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($pay_stime)];
|
||||
}
|
||||
if($pay_etime !== ''){
|
||||
$where['createtime'] = ['<=', strtotime($pay_etime.' 23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($pay_etime)];
|
||||
}
|
||||
if(!empty($pay_stime) && !empty($pay_etime)){
|
||||
$where['createtime'] = ['between',[strtotime($pay_stime),strtotime($pay_etime.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($pay_stime),strtotime($pay_etime)]];
|
||||
}
|
||||
if($pay_status !== ''){
|
||||
$where['pay_status'] = $pay_status;
|
||||
@@ -325,7 +330,7 @@ class Statistical extends adminApi
|
||||
}
|
||||
|
||||
$count = db::name('vs_user_recharge')->where($where)->count();
|
||||
$lists = db::name('vs_user_recharge')->where($where)->page($page, $page_limit)->select();
|
||||
$lists = db::name('vs_user_recharge')->where($where)->order('rid desc')->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['user_name'] = db::name('user')->where('id', $value['user_id'])->value('nickname').'-'.
|
||||
@@ -346,19 +351,21 @@ class Statistical extends adminApi
|
||||
];
|
||||
//总收入
|
||||
$wherew=[];
|
||||
$return_data['total_money'] = db::name('vs_user_recharge')->sum('money');
|
||||
unset($where['pay_status']);
|
||||
unset($where['pay_type']);
|
||||
$return_data['total_money'] = db::name('vs_user_recharge')->where($where)->sum('money');
|
||||
//未支付
|
||||
$return_data['unpaid_money'] = db::name('vs_user_recharge')->where('pay_status',1)->sum('money');
|
||||
$return_data['unpaid_money'] = db::name('vs_user_recharge')->where($where)->where('pay_status',1)->sum('money');
|
||||
//已支付
|
||||
$return_data['paid_money'] = db::name('vs_user_recharge')->where('pay_status',2)->sum('money');
|
||||
$return_data['paid_money'] = db::name('vs_user_recharge')->where($where)->where('pay_status',2)->sum('money');
|
||||
//微信支付
|
||||
$wherew['pay_type'] = ['in', [1,4]];
|
||||
$return_data['wx_money'] = db::name('vs_user_recharge')->where('pay_status',2)->where($wherew)->sum('money');
|
||||
$return_data['wx_money'] = db::name('vs_user_recharge')->where($where)->where('pay_status',2)->where($wherew)->sum('money');
|
||||
//支付宝支付
|
||||
$wherez['pay_type'] = ['in', [2,3]];
|
||||
$return_data['ali_money'] = db::name('vs_user_recharge')->where('pay_status',2)->where($wherez)->sum('money');
|
||||
$return_data['ali_money'] = db::name('vs_user_recharge')->where($where)->where('pay_status',2)->where($wherez)->sum('money');
|
||||
//金币数量
|
||||
$return_data['gold_num'] = db::name('vs_user_recharge')->where('pay_status',2)->sum('coin');
|
||||
$return_data['gold_num'] = db::name('vs_user_recharge')->where($where)->where('pay_status',2)->sum('coin');
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
@@ -383,15 +390,16 @@ class Statistical extends adminApi
|
||||
$where['a.createtime'] = ['>=', strtotime($start_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if($start_time !== '' && $end_time !== ''){
|
||||
$where['a.createtime'] = ['between', [strtotime($start_time), strtotime($end_time.' 23:59:59')]];
|
||||
$where['a.createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
}
|
||||
|
||||
$count = db::name('user_exchange')->where($where)->alias('a')->join('user b', 'a.user_id = b.id')->count();
|
||||
$lists = db::name('user_exchange')->where($where)->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
->field('a.*,b.nickname,b.user_code')
|
||||
->order('a.id desc')
|
||||
->page($page, $page_limit)->select();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['user_name'] = $value['nickname'].'-'.$value['user_code'];
|
||||
@@ -428,10 +436,10 @@ class Statistical extends adminApi
|
||||
$where['a.createtime'] = ['>=', strtotime($start_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time.' 23:59:59')];
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if($start_time !== '' && $end_time !== ''){
|
||||
$where['a.createtime'] = ['between', [strtotime($start_time), strtotime($end_time.' 23:59:59')]];
|
||||
$where['a.createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
}
|
||||
$count = db::name('vs_admin_recharge_log')
|
||||
->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
|
||||
@@ -33,6 +33,10 @@ class SysSet extends adminApi
|
||||
'8' => '房间配置',
|
||||
'9' => '弹窗内容设置',
|
||||
'10' => '邀请奖励',
|
||||
'11' => '二级密码',
|
||||
];
|
||||
public $noAdminConfigType = [
|
||||
'1' => '基础设置',
|
||||
];
|
||||
|
||||
public function _initialize()
|
||||
@@ -44,14 +48,18 @@ class SysSet extends adminApi
|
||||
* 类型列表
|
||||
*/
|
||||
public function type_list(){
|
||||
$configType = $this->configType;
|
||||
if($this->auth->isSuperAdmin()){
|
||||
$configType = $this->configType;
|
||||
}else{
|
||||
$configType = $this->noAdminConfigType;
|
||||
}
|
||||
$list = [];
|
||||
$i=0;
|
||||
foreach ($configType as $k=>$v){
|
||||
$list[$i]['id'] = $k;
|
||||
$list[$i]['name'] = $v;
|
||||
$i++;
|
||||
}
|
||||
foreach ($configType as $k=>$v){
|
||||
$list[$i]['id'] = $k;
|
||||
$list[$i]['name'] = $v;
|
||||
$i++;
|
||||
}
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
@@ -90,4 +98,17 @@ class SysSet extends adminApi
|
||||
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');
|
||||
|
||||
@@ -22,7 +22,8 @@ class Tasks extends adminApi
|
||||
public $task_type = [
|
||||
'1' => '每日任务',
|
||||
'2' => '每日特殊任务',
|
||||
'3' => '平台常规任务'
|
||||
'3' => '平台常规任务',
|
||||
'4' => '师徒任务'
|
||||
];
|
||||
|
||||
public function _initialize()
|
||||
@@ -52,7 +53,7 @@ class Tasks extends adminApi
|
||||
$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'] = $this->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'):'';
|
||||
|
||||
@@ -44,6 +44,10 @@ class Theme extends adminApi
|
||||
}
|
||||
$list = db::name($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
foreach ($list as &$value) {
|
||||
$value['begin_time'] = date('Y-m-d H:i:s',$value['begin_time']);
|
||||
$value['end_time'] = date('Y-m-d H:i:s',$value['end_time']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -62,6 +66,10 @@ class Theme extends adminApi
|
||||
$auxiliary_color = input('auxiliary_color', '');
|
||||
$file_url = input('file_url', '');
|
||||
$is_active = input('is_active', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$begin_time = !empty($begin_time) ? strtotime($begin_time) : 0;
|
||||
$end_time = !empty($end_time) ? strtotime($end_time) : 0;
|
||||
$data = [
|
||||
'theme_name' => $theme_name,
|
||||
'theme_color' => $theme_color,
|
||||
@@ -69,7 +77,9 @@ class Theme extends adminApi
|
||||
'file_url' => $file_url,
|
||||
'is_active' => $is_active,
|
||||
'admin_id' => $admin_id,
|
||||
'createtime' => time()
|
||||
'createtime' => time(),
|
||||
'begin_time' => $begin_time,
|
||||
'end_time' => $end_time,
|
||||
];
|
||||
$res = db::name($this->table)->insert($data);
|
||||
if($res){
|
||||
@@ -87,6 +97,10 @@ class Theme extends adminApi
|
||||
$auxiliary_color = input('auxiliary_color', '');
|
||||
$file_url = input('file_url', '');
|
||||
$is_active = input('is_active', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$begin_time = !empty($begin_time) ? strtotime($begin_time) : 0;
|
||||
$end_time = !empty($end_time) ? strtotime($end_time) : 0;
|
||||
$id = input('id', '');
|
||||
$data = [
|
||||
'theme_name' => $theme_name,
|
||||
@@ -94,7 +108,9 @@ class Theme extends adminApi
|
||||
'auxiliary_color' => $auxiliary_color,
|
||||
'file_url' => $file_url,
|
||||
'is_active' => $is_active,
|
||||
'updatetime' => time()
|
||||
'updatetime' => time(),
|
||||
'begin_time' => $begin_time,
|
||||
'end_time' => $end_time,
|
||||
];
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
|
||||
@@ -159,7 +159,7 @@ class Underage extends adminApi
|
||||
*/
|
||||
public function content_List(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('pageSize', 30);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$search_name = input('search_name', '');
|
||||
$where = [];
|
||||
if($search_name){
|
||||
@@ -167,6 +167,7 @@ class Underage extends adminApi
|
||||
}
|
||||
$list = DB::name('vs_underage_mode_content')->where($where)->order('sort,id', 'asc')->page($page, $page_limit)->select();
|
||||
$count = DB::name('vs_underage_mode_content')->where($where)->count();
|
||||
$return_lists = [];
|
||||
foreach ($list as $key => $value) {
|
||||
$return_lists[$key]['id'] = $value['id'];
|
||||
$return_lists[$key]['type_id'] = $value['type_id'];
|
||||
@@ -266,7 +267,7 @@ class Underage extends adminApi
|
||||
$type_id = input('type_id', '');
|
||||
$title = input('title', '');
|
||||
$introduced = input('introduced', '');
|
||||
$content = input('content', '');
|
||||
$content = $_POST['content']??"";
|
||||
$url = input('url', '');
|
||||
$img = input('img', '');
|
||||
$from = input('from', 1);
|
||||
@@ -303,9 +304,6 @@ class Underage extends adminApi
|
||||
$data['content'] = $content;
|
||||
}
|
||||
$result = db::name('vs_underage_mode_content')->where(['id'=>$id])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败");
|
||||
}
|
||||
return V(1,"成功", ['id'=>$id]);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\Upload;
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
@@ -32,14 +33,39 @@ class UploadFile extends Upload
|
||||
try {
|
||||
// 获取临时路径和原始文件名
|
||||
$filePath = $file->getRealPath();
|
||||
$objectName = $file->getInfo('name');
|
||||
// 调用父类方法上传到 OSS
|
||||
$result = $this->uploadFile($objectName, $filePath);
|
||||
if (!$result) {
|
||||
return V(0, '上传失败,请检查OSS配置或网络', null);
|
||||
$originalName = $file->getInfo('name');
|
||||
|
||||
// 提取文件扩展名
|
||||
$extension = pathinfo($originalName, PATHINFO_EXTENSION);
|
||||
|
||||
// 处理文件名(中文转拼音) 移除扩展名(如果有的话)
|
||||
$fileName = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
if (preg_match('/[\x{4e00}-\x{9fa5}]+/u', $fileName)) {
|
||||
$pinyin = new Pinyin();
|
||||
$fileName = $pinyin->permalink($fileName, ''); // 转换为无分隔符的拼音
|
||||
}
|
||||
// 返回访问地址
|
||||
$url = $this->config['oss_cdn_url'] . $objectName;
|
||||
|
||||
// 去除文件名中的空格
|
||||
$fileName = str_replace(' ', '', $fileName);
|
||||
|
||||
// 添加唯一标识符(时间戳+随机数)
|
||||
$uniqueId = time() . mt_rand(1000, 9999);
|
||||
$objectName = $fileName . '_' . $uniqueId . '.' . $extension;
|
||||
|
||||
// 调用父类方法上传到 OSS
|
||||
// $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, '上传失败,请检查COS配置或网络', null);
|
||||
}
|
||||
$url = $result;// 返回访问地址 具体访问地址根据你的实际配置来定这个需要修改 等域名通过备案后修改
|
||||
return V(1, '上传成功', ['url' => $url]);
|
||||
} catch (\Exception $e) {
|
||||
return V(0, '上传异常: ' . $e->getMessage(), null);
|
||||
|
||||
@@ -72,10 +72,12 @@ class User extends adminApi
|
||||
if($v=='coin1'){
|
||||
$where['c.coin'] = ['>=',$input_data];
|
||||
}elseif($v=='coin2'){
|
||||
$where['c.coin'] = ['<=',$input_data];
|
||||
if($input_data){
|
||||
$where['c.coin'] = ['<=',$input_data];
|
||||
}
|
||||
}elseif($v=='createtime'){
|
||||
$where['a.createtime'] = ['>=',strtotime($input_data.' 00:00:00')];
|
||||
$where['a.createtime'] = ['<=',strtotime($input_data.' 23:59:59')];
|
||||
$where['a.createtime'] = ['>=',strtotime($input_data)];
|
||||
$where['a.createtime'] = ['<=',strtotime($input_data)];
|
||||
}else{
|
||||
$where['a.'.$v] = $input_data;
|
||||
}
|
||||
@@ -231,7 +233,8 @@ class User extends adminApi
|
||||
'type' => $type,
|
||||
'type_text' => $type_text,
|
||||
];
|
||||
$res = Db::name('block')->where($map)->delete();
|
||||
Db::name('block')->where($map)->delete();
|
||||
Db::name('sms_error')->where(['mobile' => $user_info['mobile']])->delete();
|
||||
}
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
@@ -346,7 +349,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'];
|
||||
@@ -435,7 +447,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] = [
|
||||
@@ -455,6 +475,14 @@ class User extends adminApi
|
||||
return V(1,"操作成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取用户资金类型
|
||||
*/
|
||||
public function get_money_type(){
|
||||
$reslut = model('UserWallet')->getChangeTypeLableList();
|
||||
return V(1,"操作成功", $reslut);
|
||||
}
|
||||
|
||||
/*
|
||||
* 相册列表
|
||||
*/
|
||||
@@ -735,7 +763,12 @@ class User extends adminApi
|
||||
* 用户列表
|
||||
*/
|
||||
public function get_user_list(){
|
||||
$user = db::name('user')->field('id,nickname,avatar')->where(['status'=>1,'is_robot'=>0,'delete_time'=>0])->select();
|
||||
$user_code = input('user_code', 0);
|
||||
$where = [];
|
||||
if($user_code){
|
||||
$where['user_code'] = $user_code;
|
||||
}
|
||||
$user = db::name('user')->field('id,nickname,avatar')->where($where)->where(['status'=>1,'is_robot'=>0,'delete_time'=>0])->select();
|
||||
return V(1,"操作成功", $user);
|
||||
}
|
||||
}
|
||||
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, '操作失败');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class Version extends adminApi
|
||||
$version = input('version', '');
|
||||
$type = input('type', '');
|
||||
$downloadurl = input('downloadurl', '');
|
||||
$content = input('content', '');
|
||||
$content = $_POST['content'] ?? '';
|
||||
$enforce = input('enforce', '');
|
||||
$version_code = input('version_code', '');
|
||||
$status = input('status', 1);
|
||||
@@ -101,7 +101,7 @@ class Version extends adminApi
|
||||
$version = input('version', '');
|
||||
$type = input('type', '');
|
||||
$downloadurl = input('downloadurl', '');
|
||||
$content = input('content', '');
|
||||
$content = $_POST['content'] ?? '';
|
||||
$enforce = input('enforce', '');
|
||||
$version_code = input('version_code', '');
|
||||
$status = input('status', 1);
|
||||
|
||||
@@ -60,10 +60,10 @@ class Withdrawal extends adminApi
|
||||
$where['a.createtime'] = ['>=', strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime !== ''){
|
||||
$where['a.createtime'] = ['<=', strtotime($search_etime.' 23:59:59')];
|
||||
$where['a.createtime'] = ['<=', strtotime($search_etime)];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where['a.createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
$where['a.createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime)]];
|
||||
}
|
||||
$count = db::name('vs_user_withdrawal')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
@@ -75,6 +75,7 @@ class Withdrawal extends adminApi
|
||||
->field('a.*,b.nickname,b.user_code')
|
||||
->order('a.createtime desc')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$data_lists = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
@@ -255,19 +256,23 @@ class Withdrawal extends adminApi
|
||||
//查询该用户云账户提现金额
|
||||
$had_money = db::name('vs_user_withdrawal')->where(['user_id'=>$withdraw_info['user_id'],'deal_type'=>2,'status'=>6])->where('pay_time','month')->sum('general_money');
|
||||
$max_month_money = 98000;
|
||||
if(($had_money+$withdraw_info['general_money']) >= 98000){
|
||||
if(($had_money+$withdraw_info['general_money']) >= $max_month_money){
|
||||
return ['code' => 0, 'msg' => '单人单月云账户提现金额最大为98000元!', 'data' => null];
|
||||
}
|
||||
//查询该用户信息
|
||||
$user_info = model('api/user')->get_user_info($withdraw_info['user_id']);
|
||||
$user_info = model('api/user')->get_user_info($withdraw_info['user_id'], ['user','user_auth']);
|
||||
if(empty($user_info)){
|
||||
return ['code' => 0, 'msg' => '用户信息错误!', 'data' => null];
|
||||
}
|
||||
|
||||
$real_name = $user_info['real_name'];
|
||||
$id_card = $user_info['card_id'];
|
||||
$order_id = $withdraw_info['order_sn'];
|
||||
$order_amount = $withdraw_info['general_money'];
|
||||
$phone = $user_info['mobile'];
|
||||
if(empty($phone)) {
|
||||
return ['code' => 0, 'msg' => '请先绑定手机号', 'data' => null];
|
||||
}
|
||||
if (empty($real_name) || empty($id_card)) {
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
}
|
||||
@@ -281,7 +286,11 @@ class Withdrawal extends adminApi
|
||||
}
|
||||
$card_no = $user_info['alipay_account'];
|
||||
$yun_pay = new YunPay($order_id, $real_name, $id_card, $card_no, $order_amount,$phone);
|
||||
$result = $yun_pay->alipay();
|
||||
$user_data = [
|
||||
'nickname' => $user_info['nickname'],
|
||||
'user_id' => $withdraw_info['user_id'],
|
||||
];
|
||||
$result = $yun_pay->alipay($user_data);
|
||||
} elseif ($withdraw_info['type'] == 3) {
|
||||
if(empty($user_info['bank_card_number'])){
|
||||
return ['code' => 0, 'msg' => '请先绑定银行卡号', 'data' => null];
|
||||
|
||||
@@ -85,7 +85,7 @@ class Guild extends Model
|
||||
->alias('g')
|
||||
->join('vs_guild gg','g.guild_id = gg.id')
|
||||
->field('gg.*')
|
||||
->where(['g.user_id' => $user_id])
|
||||
->where(['g.user_id' => $user_id,'g.status' => 1,'g.delete_time' => 0])
|
||||
->find();
|
||||
return $guild;
|
||||
}
|
||||
@@ -95,31 +95,29 @@ class Guild extends Model
|
||||
*工会当日流水
|
||||
*/
|
||||
public function getTodayMoney($guild_id,$stoday="",$etoday=""){
|
||||
$where = [];
|
||||
if(empty($stoday) && empty($etoday)){
|
||||
$stoday = strtotime(date('Y-m-d 00:00:00'));
|
||||
$etoday = strtotime(date('Y-m-d 23:59:59'));
|
||||
$where['createtime'] = ['between', [$stoday, $etoday]];
|
||||
}else{
|
||||
if(!empty($stoday)){
|
||||
$where['createtime'] = ['>=', strtotime($stoday."00:00:00")];
|
||||
}
|
||||
if(!empty($etoday)){
|
||||
$where['createtime'] = ['<=', strtotime($etoday." 23:59:59")];
|
||||
}
|
||||
if(!empty($stoday) && !empty($etoday)){
|
||||
$where['createtime'] = ['between', [strtotime($stoday." 00:00:00"), strtotime($etoday." 23:59:59")]];
|
||||
}
|
||||
}
|
||||
|
||||
//获取所有工会房间ID
|
||||
$room_ids = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id')->select();
|
||||
$room_ids = array_column($room_ids, 'room_id');
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$room_ids)
|
||||
->where(['from'=>['in',[2,3,6]]])
|
||||
->where($where)
|
||||
->sum('total_price');
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id,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($stoday);
|
||||
$etoday_seach = strtotime($etoday);
|
||||
}
|
||||
if($v['createtime'] && $stoday_seach < $v['createtime']){
|
||||
$stoday_seach = $v['createtime'];
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,19 +75,37 @@ class Room extends Model
|
||||
$give_where['from_id'] = $room_id;
|
||||
$give_where['from'] = ["in",[2,3,6]];
|
||||
if(!empty($stime)){
|
||||
$give_where['createtime'] = ['>=',strtotime($stime.' 00:00:00')];
|
||||
$give_where['createtime'] = ['>=',strtotime($stime)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$give_where['createtime'] = ['<=',strtotime($etime.' 23:59:59')];
|
||||
$give_where['createtime'] = ['<=',strtotime($etime)];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$give_where['createtime'] = ['between',[strtotime($stime.' 00:00:00'),strtotime($etime.' 23:59:59')]];
|
||||
$give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||
}
|
||||
$total_price = db::name('vs_give_gift')->where($give_where)
|
||||
->sum('total_price');
|
||||
return $total_price;
|
||||
}
|
||||
|
||||
/*
|
||||
* 房间绑定盘
|
||||
*/
|
||||
public function bindPan($room_id){
|
||||
db::name('vs_room_pan')->where(['room_id'=>$room_id])->delete();
|
||||
$gift_bag = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>['in',[10,11,12,13]]])->select();
|
||||
foreach ($gift_bag as $k=>$v){
|
||||
$data = [
|
||||
'room_id'=>$room_id,
|
||||
'gift_bag_id'=>$v['gift_bag_id'],
|
||||
'gift_bag_detail_id'=>$v['id'],
|
||||
'remaining_number'=>$v['quantity'],
|
||||
'createtime'=>time()
|
||||
];
|
||||
db::name('vs_room_pan')->insert($data);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class Activities extends BaseCom
|
||||
$data['name'] = $activities_title??"";
|
||||
$data['gift_bag'] = [];
|
||||
foreach ($gift_bag as $k=>$v){
|
||||
$data['gift_bag'][$k]['gift_bag_id'] = $v['id']??0;
|
||||
$data['gift_bag'][$k]['name'] = $v['title']??"";
|
||||
$ext = json_decode($v['ext'],true);
|
||||
$data['gift_bag'][$k]['title1'] = $ext['title1']??"";
|
||||
@@ -49,17 +50,19 @@ class Activities extends BaseCom
|
||||
$list[$kk]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}elseif ($vv['type'] == 2) {
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$vv['foreign_id']])->find();
|
||||
$list[$kk]['gift_name'] = $gift['gift_name'];
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['gift_price'] = $gift['gift_price'];
|
||||
$list[$kk]['type'] =2;
|
||||
$list[$kk]['base_image'] = $gift['base_image'];
|
||||
if($gift){
|
||||
$list[$kk]['gift_name'] = $gift['gift_name'];
|
||||
$list[$kk]['num'] = $vv['quantity']." 个";
|
||||
$list[$kk]['gift_price'] = $gift['gift_price'];
|
||||
$list[$kk]['type'] =2;
|
||||
$list[$kk]['base_image'] = $gift['base_image'];
|
||||
}
|
||||
} elseif ($vv['type'] == 3) {
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$vv['foreign_id']])->find();
|
||||
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'] ?? "";
|
||||
@@ -85,8 +88,8 @@ class Activities extends BaseCom
|
||||
$uid = input('uid',$this->uid);
|
||||
$permission_status = 1;
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->find();
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
if(!$app_version){
|
||||
@@ -127,46 +130,51 @@ class Activities extends BaseCom
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->find();
|
||||
$data = [];
|
||||
$data['gift_bag_id'] = $gift_bag['id']??0;
|
||||
$data['name'] = $activities['title']??"";
|
||||
$data['bag_name'] = $gift_bag['title']??"";
|
||||
$data['effective_time'] = $activities['effective_time']??"";
|
||||
//规则
|
||||
$data['rule'] = get_system_config_value('web_site')."/api/Page/page_show?id=13";
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
$data['money'] = $ext['money'];
|
||||
$data['counter']['counter'] = $ext['counter'];
|
||||
$data['counter']['money'] = $ext['money_str'];
|
||||
$data['counter']['diamond'] = $ext['diamond'];
|
||||
$data['money'] = $gift_bag['money'];
|
||||
$data['counter'] = $ext['counter'];
|
||||
$data['money_str'] = $ext['money_str'];
|
||||
$data['diamond'] = $ext['diamond'];
|
||||
$data['effective_time'] = $ext['activity_end_time']??"";
|
||||
if(strtotime($ext['activity_end_time']) < time()){
|
||||
return V(0,'活动已结束!',null);
|
||||
}
|
||||
$detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag['id']])->select();
|
||||
$data['gift_list'] = [];
|
||||
foreach ($detail as $k=>$v){
|
||||
if($v['type'] == 1){
|
||||
$list[$k]['name'] = "金币";
|
||||
$list[$k]['gift_name'] = "金币";
|
||||
$list[$k]['num'] = $v['gold'];
|
||||
$list[$k]['gold'] = $v['gold'];
|
||||
$list[$k]['gift_price'] = $v['gold'];
|
||||
$list[$k]['type'] = 1;
|
||||
$list[$k]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
$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]['name'] = $gift['gift_name'];
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gold'] = $gift['gift_price'];
|
||||
$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]['icon'] = $gift['play_image'];
|
||||
$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]['name'] = $gift['title']; //装扮名称
|
||||
$list[$k]['num'] = $decorate_price['day']; //天数
|
||||
$list[$k]['gold'] = $decorate_price['price']; //价格
|
||||
$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]['icon'] = $gift['base_image'];
|
||||
$list[$k]['base_image'] = $gift['base_image'];
|
||||
}elseif($v['type'] == 4) {
|
||||
$list[$k]['name'] = "钻石";
|
||||
$list[$k]['gift_name'] = "钻石";
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gold'] = $v['gold'];
|
||||
$list[$k]['gift_price'] = $v['gold'];
|
||||
$list[$k]['type'] = 4;
|
||||
$list[$k]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
$list[$k]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}
|
||||
}
|
||||
$data['gift_list'] = $list;
|
||||
@@ -177,20 +185,183 @@ class Activities extends BaseCom
|
||||
{
|
||||
$activities_id = 3;//天降好礼
|
||||
$uid = input('uid',$this->uid);
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->find();
|
||||
if($permission){
|
||||
return V(1,'操作成功', ['permission'=>0]);
|
||||
}else{
|
||||
return V(1,'操作成功', ['permission'=>1]);
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>3,'status'=>1])->find();
|
||||
$permission = 0;
|
||||
if($gift_bag){
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
if($ext['activity_end_time'] <= time()){
|
||||
$permission = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return V(1,'操作成功', ['permission'=>$permission]);
|
||||
}
|
||||
//天降好礼发放
|
||||
public function drop_gift_send()
|
||||
{
|
||||
$uid = input('uid',$this->uid);
|
||||
$reslut = model('Activities')->drop_gift_send($uid);
|
||||
$reslut = model('Activities')->drop_gift_send($uid,16);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//新人好礼
|
||||
public function new_charge_gift()
|
||||
{
|
||||
//活动信息
|
||||
$activities_id = 7;
|
||||
$activities_title = DB::name('vs_activities')->where(['id'=>$activities_id,'status'=>1,'delete_time'=>0])->value('title');
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->select();
|
||||
$data = [];
|
||||
$data['name'] = $activities_title??"";
|
||||
$data['gift_bag'] = [];
|
||||
//一键领取
|
||||
$bag_receive_all = DB::name('vs_gift_bag_receive_log')->where(['gift_bag_id'=>17,'user_id'=>$this->uid])->find();
|
||||
foreach ($gift_bag as $k=>$v){
|
||||
$data['gift_bag'][$k]['gift_bag_id'] = $v['id']??0;
|
||||
$data['gift_bag'][$k]['name'] = $v['title']??"";
|
||||
$ext = json_decode($v['ext'],true);
|
||||
$data['gift_bag'][$k]['title1'] = $ext['title1']??"";
|
||||
$data['gift_bag'][$k]['title2'] = $ext['title2']??"";
|
||||
$data['gift_bag'][$k]['money'] = $ext['money'];
|
||||
$data['gift_bag'][$k]['gift_list'] = [];
|
||||
$detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$v['id']])->select();
|
||||
$list = [];
|
||||
foreach ($detail as $kk=>$vv){
|
||||
if($vv['type'] == 1){
|
||||
$list[$kk]['gift_name'] = "金币";
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['gift_price'] = $vv['gold'];
|
||||
$list[$kk]['type'] = 1;
|
||||
$list[$kk]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}elseif ($vv['type'] == 2) {
|
||||
$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]['gift_price'] = $gift['gift_price'];
|
||||
$list[$kk]['type'] =2;
|
||||
$list[$kk]['base_image'] = $gift['base_image'];
|
||||
}
|
||||
} elseif ($vv['type'] == 3) {
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$vv['foreign_id']])->find();
|
||||
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]['gift_price'] = $decorate_price['price']??0; //价格
|
||||
$list[$kk]['type'] =3;
|
||||
$list[$kk]['base_image'] = $gift['base_image'] ?? "";
|
||||
}
|
||||
|
||||
}elseif ($vv['type'] == 4) {
|
||||
$list[$kk]['gift_name'] = "钻石";
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['gift_price'] = $vv['gold'];
|
||||
$list[$kk]['type'] = 4;
|
||||
$list[$kk]['base_image'] = localpath_to_netpath("static/image/icon/diamond.png");
|
||||
}
|
||||
}
|
||||
$data['gift_bag'][$k]['gift_list'] = array_values($list);
|
||||
if($bag_receive_all){
|
||||
$data['gift_bag'][$k]['status'] = 0;
|
||||
}else{
|
||||
if($v['id']!=17){
|
||||
$bag_receive_log = DB::name('vs_gift_bag_receive_log')->where(['gift_bag_id'=>$v['id'],'user_id'=>$this->uid])->find();
|
||||
if($bag_receive_log){
|
||||
$data['gift_bag'][$k]['status'] = 0;
|
||||
} else {
|
||||
$data['gift_bag'][$k]['status'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return V(1,'操作成功', $data);
|
||||
}
|
||||
|
||||
//新人好礼发放
|
||||
public function new_charge_gift_receive()
|
||||
{
|
||||
$uid = input('uid',$this->uid);
|
||||
$money = input('money',0);
|
||||
$reslut = model('Activities')->new_charge_gift_send($uid,$money);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 活动权限
|
||||
*/
|
||||
public function activities_permission(){
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
if(!$app_version){
|
||||
$app_version = input('App-Version');
|
||||
}
|
||||
$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);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
//首充
|
||||
$activities_id = 1;
|
||||
$uid = input('uid',$this->uid);
|
||||
$first_charge_permission = 1;
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
|
||||
if($is_first_charge > 0){
|
||||
$first_charge_permission = 0;
|
||||
}
|
||||
if($permission){
|
||||
$first_charge_permission = 0;
|
||||
}
|
||||
|
||||
//天降好礼
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>3,'status'=>1])->find();
|
||||
$day_drop_permission = 0;
|
||||
if($gift_bag){
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
if(strtotime($ext['activity_end_time']) >= time()){
|
||||
$day_drop_permission = 1;
|
||||
}
|
||||
}
|
||||
//新人充值好礼
|
||||
$activities = DB::name('vs_activities')->where(['id'=>7,'status'=>1,'delete_time'=>0])->find();
|
||||
if($activities){
|
||||
$effective_time = $activities['effective_time'];
|
||||
}else{
|
||||
$effective_time = 0;
|
||||
}
|
||||
$bag_data = DB::name('vs_gift_bag')->where(['activities_id'=>7,'status'=>1,'delete_time'=>0])->select();
|
||||
$bag_receive_log = DB::name('vs_gift_bag_receive_log')->where(['gift_bag_id'=>['in',array_column($bag_data,'id')],'user_id'=>$uid])->select();
|
||||
$new_permission = 0;
|
||||
$user_info = DB::name('user')->where(['id'=>$uid])->find();
|
||||
if($user_info['createtime']<"1760666400"){
|
||||
$user_info['createtime'] = 1760666400;
|
||||
}
|
||||
if($user_info['createtime'] + $effective_time >= time()){
|
||||
$new_permission = 1;
|
||||
}
|
||||
$gift_bag_log_ids = array_column($bag_receive_log,'gift_bag_id');
|
||||
if(in_array(17,$gift_bag_log_ids)){
|
||||
$new_permission = 0;
|
||||
}else{
|
||||
$gift_bag_log_ids = array_intersect([14,15,16],$gift_bag_log_ids);
|
||||
if(count($gift_bag_log_ids) == 3){
|
||||
$new_permission = 0;
|
||||
}
|
||||
}
|
||||
return V(1,'操作成功',[
|
||||
'first_charge_permission'=>$first_charge_permission,
|
||||
'day_drop_permission'=>$day_drop_permission,
|
||||
'n_people_permission'=>$new_permission
|
||||
],$api_version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
131
application/api/controller/BlindBoxTurntable.php
Normal file
131
application/api/controller/BlindBoxTurntable.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
/*
|
||||
* 盲盒转盘
|
||||
* 2025-08-16
|
||||
*/
|
||||
|
||||
class BlindBoxTurntable extends BaseCom
|
||||
{
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取活动奖池礼物列表
|
||||
*/
|
||||
public function get_gift_list(){
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('BlindBoxTurntableGift')->get_gift_list($gift_bag_id,$room_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 抽奖
|
||||
*
|
||||
*/
|
||||
public function draw_gift(){
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$user_id = $this->uid;
|
||||
$room_id = input('room_id',0);
|
||||
$gift_user_ids = input('gift_user_ids',0);
|
||||
$num = input('num',1);
|
||||
$heart_id = input('heart_id',0);
|
||||
$auction_id = input('auction_id',0);
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 礼物发放
|
||||
*/
|
||||
public function gift_send(){
|
||||
// $key_name = "api:blind_box_turntable:gift_send:" . $this->uid;
|
||||
// redis_lock_exit($key_name);
|
||||
$send_id = input('send_id',0);
|
||||
$reslut = model('BlindBoxTurntableGift')->gift_send($send_id);
|
||||
// redis_unlock($key_name);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取我的抽奖记录
|
||||
*/
|
||||
public function get_my_record(){
|
||||
$user_id = $this->uid;
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$reslut = model('BlindBoxTurntableGift')->get_user_record($gift_bag_id,$user_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取全服抽奖记录
|
||||
*/
|
||||
public function get_all_record(){
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 巡乐会
|
||||
*/
|
||||
public function xlh(){
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('BlindBoxTurntableGift')->xlh_gift_list($room_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 巡乐会抽奖
|
||||
*/
|
||||
public function xlh_draw_gift(){
|
||||
$user_id = $this->uid;
|
||||
$room_id = input('room_id',0);
|
||||
$num = input('num',1);
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->xlh_draw_gift($user_id,$num,$room_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 获取我的巡乐会记录
|
||||
*/
|
||||
public function get_xlh_my_record(){
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$user_id = $this->uid;
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('BlindBoxTurntableGift')->xlh_get_user_record($user_id,$room_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 获取全服巡乐会记录(榜单)
|
||||
*/
|
||||
public function get_xlh_all_record(){
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('BlindBoxTurntableGift')->xlh_ranking($room_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 巡乐会榜单 (以期数显示)
|
||||
*/
|
||||
public function get_xlh_ranking(){
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('BlindBoxTurntableGift')->xlh_ranking_list($room_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,12 @@ use think\Controller;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
class Ceshi extends Controller
|
||||
class Ceshi extends Controllers
|
||||
{
|
||||
//测试 发送各种消息
|
||||
|
||||
//设置白名单ip访问本类接口
|
||||
protected $allowIp = [
|
||||
'113.201.181.82'
|
||||
];
|
||||
|
||||
//发送群组系统消息
|
||||
public function send_group_system_notification()
|
||||
@@ -148,8 +150,15 @@ class Ceshi extends Controller
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
public function clear_data()
|
||||
public function qing_chu_data()
|
||||
{
|
||||
//ip
|
||||
$ip = request()->ip();
|
||||
//白名单
|
||||
$white_list = $this -> allowIp;
|
||||
if (!in_array($ip, $white_list)) {
|
||||
return V(301, '非法访问!');
|
||||
}
|
||||
$i = 0;
|
||||
$res = [];
|
||||
//开启事务
|
||||
@@ -202,17 +211,17 @@ class Ceshi extends Controller
|
||||
|
||||
|
||||
$user = db::name('user')->where('id','>', 0)->select();
|
||||
if($user){
|
||||
foreach ($user as &$v){
|
||||
if($v['id']){
|
||||
$j = 0;
|
||||
$data[$j] = [
|
||||
'UserID' => 'u'.$v['id'],
|
||||
];
|
||||
}
|
||||
model('Tencent')->account_deletes($data);
|
||||
}
|
||||
}
|
||||
// if($user){
|
||||
// foreach ($user as &$v){
|
||||
// if($v['id']){
|
||||
// $j = 0;
|
||||
// $data[$j] = [
|
||||
// 'UserID' => 'u'.$v['id'],
|
||||
// ];
|
||||
// }
|
||||
// // model('Tencent')->account_deletes($data);
|
||||
// }
|
||||
// }
|
||||
|
||||
$reslut9 = db::name('user')->where('id','>', 0)->delete();
|
||||
if($reslut9){
|
||||
@@ -449,9 +458,9 @@ class Ceshi extends Controller
|
||||
|
||||
//删除腾讯房间
|
||||
$room = db::name('vs_room')->select();
|
||||
foreach ($room as &$value){
|
||||
model('Tencent')->delete_group('room'.$value['id']);
|
||||
}
|
||||
// foreach ($room as &$value){
|
||||
// // model('Tencent')->delete_group('room'.$value['id']);
|
||||
// }
|
||||
$reslut35 = db::name('vs_room')->where('id','>', 0)->delete();
|
||||
if($reslut35){
|
||||
$i++ ;
|
||||
@@ -763,7 +772,70 @@ class Ceshi extends Controller
|
||||
//数组末尾添加元素
|
||||
array_push($res, '财富等级日志删除失败!');
|
||||
}
|
||||
$reslut68 = db::name('vs_user_friending')->where('id','>', 0)->delete();
|
||||
if($reslut68){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友删除失败!');
|
||||
}
|
||||
$reslut69 = db::name('vs_user_friending_heart')->where('id','>', 0)->delete();
|
||||
if($reslut69){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友心跳删除失败!');
|
||||
}
|
||||
$reslut70 = db::name('vs_room_hot_value_log')->where('id','>', 0)->delete();
|
||||
if($reslut70){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间热度值日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut71 = db::name('vs_blind_box_turntable_results_log')->where('id','>', 0)->delete();
|
||||
if($reslut71){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘结果日志删除失败!');
|
||||
}
|
||||
$reslut72 = db::name('vs_blind_box_turntable_log')->where('id','>', 0)->delete();
|
||||
if($reslut72){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘日志删除失败!');
|
||||
}
|
||||
$reslut73 = db::name('vs_room_pan_xlh')->where('id','>', 0)->delete();
|
||||
if($reslut73){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会删除失败!');
|
||||
}
|
||||
$reslut74 = db::name('vs_room_pan_xlh_log')->where('id','>', 0)->delete();
|
||||
if($reslut74){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会日志删除失败!');
|
||||
}
|
||||
$reslut75 = db::name('vs_room_pan')->where('id','>', 0)->delete();
|
||||
if($reslut75){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间盘删除失败!');
|
||||
}
|
||||
$reslut76 = db::name('vs_gift_bag_receive_pan_log')->where('id','>', 0)->delete();
|
||||
if($reslut76){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '礼物背包领取盘日志删除失败!');
|
||||
}
|
||||
|
||||
//数据提交
|
||||
db::commit();
|
||||
@@ -791,6 +863,27 @@ class Ceshi extends Controller
|
||||
|
||||
|
||||
|
||||
//测试异步信息
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,10 +18,37 @@ class Cron
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
|
||||
//经业务调整 暂时不要了
|
||||
//每10秒执行
|
||||
public function TenSeconds()
|
||||
{
|
||||
$cron = new \app\cron\controller\TenSeconds();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//每天执行
|
||||
public function DaySeconds()
|
||||
{
|
||||
$cron = new \app\cron\controller\DaySeconds();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//巡乐会结束 礼物发放
|
||||
public function XlhSend(){
|
||||
$cron = new \app\cron\controller\RoomPan();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//交友房结束
|
||||
public function FriendEnd(){
|
||||
$cron = new \app\cron\controller\FriendEnd();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//房间小时榜发礼物(每小时执行一次)
|
||||
public function RoomHourRanking(){
|
||||
$cron = new \app\cron\controller\RoomHourRanking();
|
||||
$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);
|
||||
}
|
||||
}
|
||||
65
application/api/controller/Friend.php
Normal file
65
application/api/controller/Friend.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class Friend extends BaseCom
|
||||
{
|
||||
//交友开始
|
||||
public function start_friend(){
|
||||
$key_name = "api:friend:start_friend:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$room_id = input('room_id', '');
|
||||
$reslut = model('Friend')->start_friend($this->uid,$room_id);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//交友延时
|
||||
public function delay(){
|
||||
$friend_id = input('friend_id', '');
|
||||
$room_id = input('room_id', '');
|
||||
$delay_times = input('delay_times', '');//分钟
|
||||
|
||||
$reslut = model('Friend')->delay($this->uid,$room_id,$friend_id,$delay_times);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//交友结束
|
||||
public function end_friend(){
|
||||
|
||||
$friend_id = input('friend_id', '');
|
||||
$room_id = input('room_id', '');
|
||||
|
||||
$result = model('Friend')->end_friend($this->uid,$room_id,$friend_id);
|
||||
|
||||
return V($result['code'], $result['msg'], $result['data']);
|
||||
}
|
||||
|
||||
//卡关系 创建关系
|
||||
public function create_relation()
|
||||
{
|
||||
$key_name = "api:friend:create_relation:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$room_id = input('room_id', '');
|
||||
$friend_id = input('friend_id', '');
|
||||
$user1_id = input('user1_id', '');
|
||||
$user2_id = input('user2_id', '');
|
||||
$relation_id = input('relation_id', '');
|
||||
$result = model('Friend')->createRelation($this->uid,$room_id,$friend_id,$user1_id,$user2_id,$relation_id);
|
||||
redis_unlocks($key_name);
|
||||
return V($result['code'], $result['msg'], $result['data']);
|
||||
}
|
||||
|
||||
//退出私密小屋
|
||||
public function out_room()
|
||||
{
|
||||
$room_id = input('room_id', '');
|
||||
|
||||
$result = model('Friend')->outRoom($this->uid,$room_id);
|
||||
|
||||
return V($result['code'], $result['msg'], $result['data']);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ class Gift extends BaseCom
|
||||
public function get_gift_list()
|
||||
{
|
||||
$label = input('label',0);
|
||||
$reslut = model('Gift')->get_gift_list($label);
|
||||
$room_id = input('room_id',0);
|
||||
$user_id = $this->uid ?? 0;
|
||||
$reslut = model('Gift')->get_gift_list($label,$room_id,$user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//聊天送礼物 (音信)
|
||||
|
||||
@@ -22,7 +22,6 @@ class Guild extends BaseCom
|
||||
public function guild_list()
|
||||
{
|
||||
$page = input('page',1);
|
||||
$page = $page > 0 ? $page : 1;
|
||||
$limit = input('limit',10);
|
||||
$search = input('search_id','');
|
||||
$reslut = model('Guild')->get_guild_list($page,$limit,$search,$this->uid);
|
||||
@@ -42,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']);
|
||||
}
|
||||
@@ -64,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']);
|
||||
}
|
||||
@@ -175,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]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -197,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']);
|
||||
}
|
||||
@@ -206,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', '');
|
||||
//群聊公告
|
||||
@@ -217,5 +221,25 @@ 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);
|
||||
$reslut = model('Guild')->guild_invite_handle($uid, $apply_id, $type);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Index extends BaseCom
|
||||
$is_top = input('is_top', 0); //1非置顶2置顶
|
||||
$label_id = input('label_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$page_limit = input('page_limit', 20);
|
||||
|
||||
$reslut = model('Room')->room_list($label_id,$is_top, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data'], $reslut['api_version']);
|
||||
@@ -29,7 +29,10 @@ class Index extends BaseCom
|
||||
//房间类型列表
|
||||
public function room_type_list()
|
||||
{
|
||||
$list = db::name('vs_room_type')->where('status', 1)->field('id,type_name as label_name')->select();
|
||||
$list = db::name('vs_room_type')->where(['status' => 1, 'deletetime' => 0])->field('id,type_name as label_name')->order('sort asc')->select();
|
||||
|
||||
//给前面面添加一组数据
|
||||
array_unshift($list, ['id' => -2, 'label_name' => '练歌']);
|
||||
//给前面添加一组数据
|
||||
array_unshift($list, ['id' => -1, 'label_name' => '热门']);
|
||||
return V(1, '获取成功', $list);
|
||||
|
||||
@@ -49,6 +49,7 @@ class Invited extends BaseCom
|
||||
}
|
||||
$reslut['init_code'] = $init_code ? $init_code:'';
|
||||
$invited_draw = get_system_config_value('invited_draw');
|
||||
$reslut['invited_draw'] = $invited_draw;
|
||||
//说明
|
||||
$reslut['explain'] = '绑定成功后,您每次充值金额的'.$invited_draw.'%'.'将以钻石形式赠送给邀请人,满足提现金额邀请人可以直接提现';
|
||||
return V(1,'操作成功',$reslut);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +66,16 @@ class Login extends Controller
|
||||
|
||||
$user_name = input('user_login');
|
||||
$sms_code = input('sms_code', ''); //短信验证码
|
||||
// $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);
|
||||
if ($ret['code'] == 0) {
|
||||
return V($ret['code'], $ret['msg'], null);
|
||||
if (\think\Env::get('app.system_type','prod') != "prod" && $sms_code == "999999999") {
|
||||
// 非正式环境且验证码为999999,直接放行
|
||||
}else{
|
||||
// $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);
|
||||
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']);
|
||||
}
|
||||
@@ -357,6 +360,7 @@ class Login extends Controller
|
||||
//注销
|
||||
public function cancel()
|
||||
{
|
||||
return V(0, '注销请联系客服', null);
|
||||
$token = input('token');
|
||||
$reslut = model('Login')->cancel($token);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['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;
|
||||
|
||||
@@ -26,18 +26,42 @@ class Payment extends Controller
|
||||
$user_id = input('user_id', 0);
|
||||
$money = input('money', 0);
|
||||
$coin = input('coin', 0);
|
||||
if(!$coin){
|
||||
$type_params = input('type_params', 0);
|
||||
$type_id = input('type_id', 0);
|
||||
$nobility_id = input('nobility_id', 0);//'0-购买金币(充值),其他是爵位id'
|
||||
if($nobility_id != 0){
|
||||
$nobility = model('Nobility')->buyNobilityPrice($user_id,$nobility_id);
|
||||
if($nobility['code'] == 0 || $nobility['data']['price'] != $money){
|
||||
return V(0, '网络错误,请重新操作!', null);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$coin && $nobility_id == 0){
|
||||
$coin = $money * get_system_config_value('rmb_coin_ratio');
|
||||
}
|
||||
if (!$user_id) {
|
||||
return V(0, '请选择充值用户', null);
|
||||
}
|
||||
//获取用户的手机号
|
||||
$user_phone = db::name('user')->where(["id" => $user_id])->value('mobile');
|
||||
if(!$user_phone){
|
||||
return V(0, '请先绑定手机号!', null);
|
||||
}
|
||||
//获取用户的实名信息
|
||||
$real_name = db::name('user_auth')->where(["mobile" => $user_phone,'is_real' => 1])->find();
|
||||
if(!$real_name){
|
||||
return V(0, '请先实名认证', null);
|
||||
}
|
||||
//获取用户的年龄
|
||||
if(!getAgeId($real_name['card_id'])){
|
||||
return V(0, '未成年不可充值!', null);
|
||||
}
|
||||
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money >= 2000) {
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money > 2000) {
|
||||
return V(0, '请选择正确的充值金额', null);
|
||||
}
|
||||
$user_code = db::name('user')->where(["id" => $user_id])->value('user_code');
|
||||
$title = "APP充值到用户 " . ($user_code ?? "") . " 余额!";
|
||||
$title = "APP充值到用户". ($user_code ?? "") ."余额!";
|
||||
|
||||
$order_number = $this->createOrderSn();
|
||||
$data['order_sn'] = $order_number;
|
||||
@@ -46,7 +70,10 @@ class Payment extends Controller
|
||||
$data['user_id'] = $user_id;
|
||||
$data['pay_type'] = $type;
|
||||
$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) {
|
||||
@@ -91,6 +118,7 @@ class Payment extends Controller
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;
|
||||
$where['pay_type']=2;
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
@@ -135,6 +163,7 @@ class Payment extends Controller
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=1;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$transaction_id
|
||||
@@ -190,6 +219,7 @@ class Payment extends Controller
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=$pay_type;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
@@ -211,21 +241,26 @@ class Payment extends Controller
|
||||
* 云账户回调(提现)
|
||||
*/
|
||||
public function yun_callback(){
|
||||
$data = input("data", "");
|
||||
$mess = input("mess", "");
|
||||
$timestamp = input("timestamp", "");
|
||||
$sign = input("sign", "");
|
||||
Log::record("云账户回调信息".json_encode($_POST),"info");
|
||||
// $data = input("data", "");
|
||||
// $mess = input("mess", "");
|
||||
// $timestamp = input("timestamp", "");
|
||||
// $sign = input("sign", "");
|
||||
$data = $_POST['data']??"";
|
||||
$mess = $_POST['mess']??"";
|
||||
$timestamp = $_POST['timestamp']?? "";
|
||||
$sign = $_POST['sign']??"";
|
||||
|
||||
write_log_redis("yunzhanghu_huidiao_原始数据",$_POST);
|
||||
$yun_pay = new YunPay();
|
||||
$result = $yun_pay->yun_callback($data,$mess,$timestamp,$sign);
|
||||
if($result['code']==1){
|
||||
$data = $result['data']['data'];
|
||||
$data = $result['data'];
|
||||
if($data){
|
||||
$status = $data['status'];
|
||||
if(!isset($data['status'])){
|
||||
echo 'fail';
|
||||
die;
|
||||
}
|
||||
$status = $data['status'];
|
||||
switch ($status){
|
||||
case "1":
|
||||
// 支付成功(对于支付宝和微信支付是最终状态,对于银行卡大部分情况是终态,小概率会出现"退汇现象",状态由"成功"变为"退汇")
|
||||
|
||||
119
application/api/controller/Redpacket.php
Normal file
119
application/api/controller/Redpacket.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use app\common\service\RedpacketService;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 红包接口
|
||||
*/
|
||||
class Redpacket extends BaseCom
|
||||
{
|
||||
|
||||
/**
|
||||
* 发红包
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
|
||||
$data['user_id'] = $this->uid;
|
||||
|
||||
$service = new RedpacketService();
|
||||
$reslut = $service->create($data);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 抢红包
|
||||
*/
|
||||
public function grab()
|
||||
{
|
||||
$redpacketId = input('redpacket_id', 0);
|
||||
|
||||
if (empty($redpacketId)) {
|
||||
return V(0, '红包ID不能为空');
|
||||
}
|
||||
|
||||
$service = new RedpacketService();
|
||||
// 在抢红包前确保状态正确
|
||||
$service->checkAndUpdateRedpacketStatus($redpacketId);
|
||||
$reslut = $service->grabWithResult($redpacketId, $this->uid);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取抢红包结果
|
||||
*/
|
||||
public function grabResult()
|
||||
{
|
||||
$redpacketId = $this->request->get('redpacket_id');
|
||||
|
||||
if (empty($redpacketId)) {
|
||||
return V(0, '红包ID不能为空');
|
||||
}
|
||||
|
||||
$service = new RedpacketService();
|
||||
$result = $service->getGrabResult($redpacketId, $this->uid);
|
||||
|
||||
if (!$result) {
|
||||
return V(0, '红包不存在');
|
||||
}
|
||||
|
||||
return V(1, '获取成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$redpacketId = input('redpacket_id', 0);
|
||||
|
||||
if (empty($redpacketId)) {
|
||||
return V(0, '红包ID不能为空');
|
||||
}
|
||||
|
||||
$service = new RedpacketService();
|
||||
// 在获取详情前确保状态正确
|
||||
$service->checkAndUpdateRedpacketStatus($redpacketId);
|
||||
$detail = $service->getDetail($redpacketId, $this->uid);
|
||||
|
||||
if (!$detail) {
|
||||
return V(0, '红包不存在');
|
||||
}
|
||||
|
||||
return V(1, '获取成功', $detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取倒计时选项
|
||||
*/
|
||||
public function countdownOptions()
|
||||
{
|
||||
$options = \app\common\model\Redpacket::$countdownOptions;
|
||||
$this->success('获取成功', $options);
|
||||
}
|
||||
|
||||
// 获取房间内红包列表
|
||||
public function roomRedPackets()
|
||||
{
|
||||
$roomId = $this->request->get('room_id');
|
||||
$result = Db::name('redpacket')->where(['room_id' => $roomId, 'status' => ['<=',1]])->select();
|
||||
if($result){
|
||||
foreach ($result as &$item) {
|
||||
$item['redpacket_id'] = $item['id'];
|
||||
$item['redpacket_time'] = get_system_config_value('red_packet_time');//展示时间
|
||||
$item['nickname'] = Db::name('user')->where('id', $item['user_id'])->value('nickname');
|
||||
$item['avatar'] = Db::name('user')->where('id', $item['user_id'])->value('avatar');
|
||||
$is_qiang = Db::name('redpacket_record')->where(['redpacket_id' => $item['id'], 'user_id' => $this->uid])->find();
|
||||
$item['is_qiang'] = $is_qiang ? 1 : 0;
|
||||
}
|
||||
}
|
||||
return V(1, '获取成功', $result);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,15 +35,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()
|
||||
@@ -149,14 +140,29 @@ class Room extends BaseCom
|
||||
//直播间送礼
|
||||
public function room_give_gift()
|
||||
{
|
||||
$key_name = "api:room:gift:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$gift_num = input('gift_num', 0);
|
||||
$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);
|
||||
|
||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number);
|
||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number,$heart_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间送礼 背包一键全清
|
||||
public function room_gift_all_clear()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$to_uid = input('to_uid', 0);//收礼人ID
|
||||
$heart_id = input('heart_id', 0);//交友
|
||||
$auction_id = input('auction_id');//竞拍
|
||||
$reslut = model('Room')->room_gift_all_clear($this->uid, $room_id, $to_uid,$heart_id,$auction_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -260,7 +266,7 @@ class Room extends BaseCom
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-点唱,2-拍卖,3-男神,4-女神
|
||||
$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']);
|
||||
}
|
||||
@@ -300,16 +306,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()
|
||||
{
|
||||
@@ -395,4 +391,42 @@ class Room extends BaseCom
|
||||
$reslut = model('Room')->room_online_number($room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//房间在线列表
|
||||
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()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$user_id = input('user_id', '');
|
||||
$reslut = model('Room')->room_user_charm_list($room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->user_reconnect($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-切后台,2-切前台
|
||||
$reslut = model('Room')->user_in_room_background($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,11 @@ 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礼物,请重新选择');
|
||||
}
|
||||
$relation_id = input('relation_id','');
|
||||
$auction_type = input('auction_type',1);//1真爱拍 2 亲密拍
|
||||
$time_day = input('time_day', 0);//小时
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
34
application/api/controller/RoomHourRanking.php
Normal file
34
application/api/controller/RoomHourRanking.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class RoomHourRanking extends BaseCom
|
||||
{
|
||||
//房间小时榜是否开启
|
||||
public function room_hour_ranking_is_open()
|
||||
{
|
||||
$open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time');
|
||||
return V(1, '获取成功', ['open_time' => $open_time]);
|
||||
}
|
||||
|
||||
//房间小时榜玩法
|
||||
public function room_hour_ranking_play()
|
||||
{
|
||||
$introd = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('introd');
|
||||
return V(1, '获取成功', ['introd' => $introd]);
|
||||
}
|
||||
|
||||
//房间小时榜
|
||||
public function room_hour_ranking()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
|
||||
$reslut = model('RoomHourRanking')->room_hour_ranking($page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,8 @@ class RoomPit extends BaseCom
|
||||
//申请上麦
|
||||
public function apply_pit()
|
||||
{
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
|
||||
$room_id = input('room_id', 0);
|
||||
$pit_number = input('pit_number', 0);
|
||||
if($room_id == 0){
|
||||
@@ -19,27 +21,19 @@ class RoomPit extends BaseCom
|
||||
if($res['code'] != 1){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
//查询房间主持麦有人吗
|
||||
$room_host_info = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
|
||||
//房主,管理,主持不受此限制
|
||||
$room_owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $this->uid])->find();
|
||||
//管理
|
||||
$room_manager = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'type' => 2,'delete_time' => null])->find();
|
||||
//主持
|
||||
$room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'type' => 1,'delete_time' => null])->find();
|
||||
if($room_host_info == 0 && !$room_owner && !$room_manager && !$room_host){
|
||||
return V(0, '上麦请联系主持', null);
|
||||
}
|
||||
|
||||
$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 == 2){
|
||||
redis_lock_exits($key_name);
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8))|| $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
}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);
|
||||
}else{
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($this->uid,$room_id,7,0,$pit_number);
|
||||
|
||||
@@ -113,9 +107,15 @@ 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 == 2){
|
||||
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)){
|
||||
}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);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class RoomSong extends BaseCom
|
||||
public function up_song(){
|
||||
$room_song_id = input('did');
|
||||
$type = input('type');//1上移,2置顶
|
||||
$res = model('RoomSong')->up_song($room_song_id,$type);
|
||||
$res = model('RoomSong')->up_song($this->uid,$room_song_id,$type);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,16 @@ class Search extends BaseCom
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'room_number' => $search,
|
||||
'apply_status' => 2
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'room_name' => ['like', '%'.$search . '%'],
|
||||
'apply_status' => 2
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}
|
||||
|
||||
@@ -84,7 +88,7 @@ class Search extends BaseCom
|
||||
$lists[$k]['picture'] = $v['room_cover'];
|
||||
$lists[$k]['code'] = $v['room_number'];
|
||||
$lists[$k]['label_icon'] = db::name('vs_room_label')->where('id', $v['label_id'])->value('label_icon');
|
||||
$lists[$k]['hot_value'] = $v['hot_value'];
|
||||
$lists[$k]['hot_value'] = $v['today_hot_value'];
|
||||
}elseif($type == 3){
|
||||
$lists[$k]['id'] = $v['id'];
|
||||
$lists[$k]['name'] = $v['guild_name'];
|
||||
@@ -96,4 +100,59 @@ class Search extends BaseCom
|
||||
|
||||
return V(1, '获取成功', $lists);
|
||||
}
|
||||
|
||||
|
||||
//搜索
|
||||
public function search_list()
|
||||
{
|
||||
$search = input('search', '');
|
||||
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'user_code' => $search,
|
||||
'status' => 1
|
||||
];
|
||||
$where1 = [
|
||||
'room_number' => $search,
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'nickname' => ['like', '%'.$search . '%'],
|
||||
'status' => 1
|
||||
];
|
||||
$where1 = [
|
||||
'room_name' => ['like', '%'.$search . '%'],
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}
|
||||
|
||||
$users = db::name('user')->field('id as user_id,nickname,avatar,user_code,sex')->where($where)->select();
|
||||
|
||||
if(isset($users)){
|
||||
foreach ($users as &$v){
|
||||
$v['room_id'] = 0;
|
||||
//是否在房间
|
||||
$is_room = db::name('vs_room_visitor')->where(['user_id' => $v['user_id'], 'is_delete' => 1])->order('id desc')->value('room_id');
|
||||
if ($is_room) {
|
||||
$v['room_id'] = $is_room;
|
||||
}
|
||||
$v['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标
|
||||
$v['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标
|
||||
}
|
||||
}
|
||||
|
||||
$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){
|
||||
$vv['label_icon'] = db::name('vs_room_label')->where('id', $vv['label_id'])->value('label_icon');
|
||||
$vv['hot_value'] = $vv['today_hot_value'];
|
||||
}
|
||||
}
|
||||
return V(1, '获取成功', ['users' => $users, 'rooms' => $rooms]);
|
||||
}
|
||||
}
|
||||
135
application/api/controller/Sign.php
Normal file
135
application/api/controller/Sign.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$user_id = input('user_id', 0);
|
||||
if ($room_id <= 0 || $user_id <= 0) {
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$reslut = model('Sign')->start_sign($this->uid, $room_id, $user_id);
|
||||
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 ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$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')->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 ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$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 ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$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 ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$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 ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
201
application/api/controller/SingerSong.php
Normal file
201
application/api/controller/SingerSong.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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, '请选择礼物');
|
||||
}
|
||||
$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, '请选择礼物');
|
||||
}
|
||||
$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', 30);
|
||||
$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']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
16
application/api/controller/Tencent.php
Normal file
16
application/api/controller/Tencent.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
class Tencent extends Controller
|
||||
{
|
||||
public function call_back()
|
||||
{
|
||||
$data = input('post.');
|
||||
$sign_data = input('get.');
|
||||
$reslut = model('Tencent')->tencent_call_back($data,$sign_data);
|
||||
return json($reslut);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,49 @@ class Theme extends controller
|
||||
}
|
||||
/*
|
||||
* 启动页列表
|
||||
* @return array
|
||||
*
|
||||
* app背景图片 app_bg
|
||||
* 首页选中 home_sel
|
||||
* 首页正常 home_nor
|
||||
* 广场选中 find_sel
|
||||
* 广场正常 find_nor
|
||||
* 消息选中 msg_sel
|
||||
* 消息正常 msg_nor
|
||||
* 我的选中 mine_sel
|
||||
* 我的正常 mine_nor
|
||||
* 主题色 theme_color
|
||||
* 按钮文字颜色 btn_text_color
|
||||
*/
|
||||
public function get_theme_data()
|
||||
{
|
||||
$reslut = DB::name('vs_theme')->where('is_active',1)->where('delete_time',0)->find();
|
||||
return V(1,'操作成功', $reslut);
|
||||
$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';
|
||||
}
|
||||
|
||||
//版本号
|
||||
$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['oldversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return V(1,'操作成功', $reslut,$api_version);
|
||||
}
|
||||
}
|
||||
|
||||
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['oldversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data'],$api_version);
|
||||
}
|
||||
|
||||
//关注(回关)
|
||||
@@ -234,6 +246,15 @@ class User extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//关注房间(红包专用)
|
||||
public function follow_room()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-收藏,0-取消收藏
|
||||
$reslut = model('user')->follow_room($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户关系卡(亲密拍)、关系位(真爱拍)
|
||||
public function user_cp_list()
|
||||
{
|
||||
@@ -264,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']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -149,4 +149,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']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,21 @@ class UserGiftPack extends BaseCom
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取背包礼物列表总值
|
||||
public function get_gift_pack_list_count()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_list_count($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//背包收入
|
||||
public function get_gift_pack_income()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$reslut = model('UserGiftPack')->income_user_gift_pack($user_id,$page=1,$page_limit=10);
|
||||
$reslut = model('UserGiftPack')->income_user_gift_pack($user_id,$page,$page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -40,7 +48,7 @@ class UserGiftPack extends BaseCom
|
||||
$user_id = $this->uid;
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_outcome($user_id,$page=1,$page_limit=10);
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_outcome($user_id,$page,$page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
41
application/api/controller/Xintiao.php
Normal file
41
application/api/controller/Xintiao.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class Xintiao extends BaseCom
|
||||
{
|
||||
|
||||
//房间内保持心跳
|
||||
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_room_heartbeat')->where(['user_id' => $user_id, 'room_id' => $room_id])->find();
|
||||
if($is_xintiao){
|
||||
db::name('vs_room_heartbeat')->where('id' , $is_xintiao['id'])->update(['updatetime' => time()]);
|
||||
}else{
|
||||
db::name('vs_room_heartbeat')->insert([
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
return V(1, '成功', null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
434
application/api/controller/Xxiaoshi.php
Normal file
434
application/api/controller/Xxiaoshi.php
Normal file
@@ -0,0 +1,434 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
use app\common\controller\Push;
|
||||
|
||||
class Xxiaoshi extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function send_gift()
|
||||
{
|
||||
//获取上一个小时的开始时间和结束时间
|
||||
$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;
|
||||
}
|
||||
//是否全局飘瓶
|
||||
$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)
|
||||
{
|
||||
$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')
|
||||
->select();
|
||||
|
||||
$rewardMap = [];
|
||||
foreach ($rewards as $reward) {
|
||||
$rankIndex = $reward['ranking'];
|
||||
|
||||
if (!isset($rewardMap[$rankIndex])) {
|
||||
$rewardMap[$rankIndex] = [
|
||||
'index' => $rankIndex,
|
||||
// 'name' => $reward['rank_name'],
|
||||
'content' => []
|
||||
];
|
||||
}
|
||||
|
||||
// 添加奖励内容到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'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 按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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -108,7 +108,7 @@ return [
|
||||
'该装扮天数不存在' => '该装扮天数不存在',
|
||||
'该个人靓号已被购买' => '该个人靓号已被购买',
|
||||
'该房间靓号已被购买' => '该房间靓号已被购买',
|
||||
'该工会靓号已被购买' => '该工会靓号已被购买',
|
||||
'该公会靓号已被购买' => '该公会靓号已被购买',
|
||||
'用户信息错误' => '用户信息错误',
|
||||
'非法资金类型' => '非法资金类型',
|
||||
'当前用户金币已达上限' => '当前用户金币已达上限',
|
||||
|
||||
@@ -25,7 +25,8 @@ class Activities extends Model
|
||||
public static function first_charge_gift_send($user_id,$money=0)
|
||||
{
|
||||
//礼包
|
||||
$gift_bag_id = DB::name('vs_gift_bag')->where(['activities_id'=>1,'status'=>1,'money'=>$money])->value('id');
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>1,'status'=>1,'delete_time'=>0,'money'=>['<=',$money]])->order('money desc')->find();
|
||||
$gift_bag_id = $gift_bag['id'] ?? 0;
|
||||
if (!$gift_bag_id) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
@@ -36,21 +37,29 @@ class Activities extends Model
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
$gift_id =0;
|
||||
$gift_price = 0;
|
||||
$gift_num = $v['quantity'];
|
||||
switch ($v['type']) {
|
||||
case 1: //金币 方法1:直接添加到用户钱包
|
||||
$gift_price = $v['quantity'];
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::FIRST_CHARGE,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::FIRST_CHARGE));
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$gift_id = $v['foreign_id'];
|
||||
$res = model('UserGiftPack')->change_user_gift_pack($user_id,$v['foreign_id'],$v['quantity'],model('UserGiftPack')::FIRST_CHARGE,"首充好礼获得礼物");
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$gift_id = $v['foreign_id'];
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
if(empty($decorate_price_info)){
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
$gift_price = $decorate_price_info['price'];
|
||||
$res = model('Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],5);
|
||||
break;
|
||||
case 4: //道具 方法5:钻石
|
||||
$gift_price = $v['quantity'];
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::FIRST_CHARGE,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::FIRST_CHARGE));
|
||||
default:
|
||||
break;
|
||||
@@ -59,15 +68,19 @@ class Activities extends Model
|
||||
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_bag_id,
|
||||
'gift_id'=> $gift_id,
|
||||
'gift_price' => $gift_price,
|
||||
'num' => $gift_num,
|
||||
'bag_price' => $money,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
// 添加活动记录
|
||||
$reslut = Db::name('vs_activities_receive')->insert([
|
||||
'user_id' => $user_id,
|
||||
@@ -86,14 +99,19 @@ class Activities extends Model
|
||||
/*
|
||||
* 天降好礼发放
|
||||
*/
|
||||
public static function drop_gift_send($user_id)
|
||||
public static function drop_gift_send($user_id,$money=0)
|
||||
{
|
||||
$activities_id = 3;
|
||||
//礼包
|
||||
$gift_bag_id = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->value('id');
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->find();
|
||||
$gift_bag_id = $gift_bag['id'] ?? 0;
|
||||
|
||||
if (!$gift_bag_id) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
if($money != $gift_bag['money']){
|
||||
return ['code' => 0, 'msg' => '充值金额未命中天降好礼礼包','data' => null];
|
||||
}
|
||||
$gift_bag_detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
if (!$gift_bag_detail) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
@@ -111,7 +129,7 @@ class Activities extends Model
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
if(empty($decorate_price_info)){
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
$res = model('Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],6);
|
||||
break;
|
||||
@@ -124,15 +142,20 @@ class Activities extends Model
|
||||
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_bag_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_bag['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
// 添加活动记录
|
||||
$reslut = Db::name('vs_activities_receive')->insert([
|
||||
'user_id' => $user_id,
|
||||
@@ -148,4 +171,85 @@ class Activities extends Model
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 新人好礼发放
|
||||
*/
|
||||
public static function new_charge_gift_send($user_id,$money=0)
|
||||
{
|
||||
//礼包
|
||||
$activities_id = 7;
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1,'delete_time'=>0,'money'=>$money])->order('money desc')->find();
|
||||
$gift_bag_id = $gift_bag['id'] ?? 0;
|
||||
if (!$gift_bag_id) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
$gift_bag_detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
if (!$gift_bag_detail) {
|
||||
return ['code' => 0, 'msg' => '礼包未配置','data' => null];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
$gift_id =0;
|
||||
$gift_price = 0;
|
||||
$gift_num = $v['quantity'];
|
||||
switch ($v['type']) {
|
||||
case 1: //金币 方法1:直接添加到用户钱包
|
||||
$gift_price = $v['quantity'];
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NEW_USER_CHARGE_GIFT,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NEW_USER_CHARGE_GIFT));
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$gift_id = $v['foreign_id'];
|
||||
$res = model('UserGiftPack')->change_user_gift_pack($user_id,$v['foreign_id'],$v['quantity'],model('UserGiftPack')::NEW_CHARGE_GIFT,"新人好礼获得礼物");
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$gift_id = $v['foreign_id'];
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
if(empty($decorate_price_info)){
|
||||
break;
|
||||
}
|
||||
$gift_price = $decorate_price_info['price'];
|
||||
$res = model('Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],8);
|
||||
break;
|
||||
case 4: //道具 方法5:钻石
|
||||
$gift_price = $v['quantity'];
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::NEW_USER_CHARGE_GIFT,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NEW_USER_CHARGE_GIFT));
|
||||
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_bag_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_bag['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
// 添加活动记录
|
||||
$reslut = Db::name('vs_activities_receive')->insert([
|
||||
'user_id' => $user_id,
|
||||
'activities_id' => 7,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,11 +9,12 @@ class Banner extends Model
|
||||
{
|
||||
protected $table = 'fa_vs_banner';
|
||||
public $ShowType = [
|
||||
// 1 => '引导页',
|
||||
// 2 => '启动页',
|
||||
1 => '引导页',
|
||||
2 => '启动页',
|
||||
3 => '首页轮播图',
|
||||
4 => '工会',
|
||||
5 => '帮助反馈'
|
||||
4 => '房间首页',
|
||||
5 => '工会列表页广告位',
|
||||
6 => '我的页面'
|
||||
];
|
||||
//1纯展示 2文章 3房间 4个人主页 5外站'
|
||||
public $Type = [
|
||||
|
||||
464
application/api/model/BlindBoxTurntableGift.php
Normal file
464
application/api/model/BlindBoxTurntableGift.php
Normal file
@@ -0,0 +1,464 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use app\common\controller\Push;
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
/*
|
||||
* 盲盒转盘
|
||||
* 2025-08-16
|
||||
*/
|
||||
class BlindBoxTurntableGift extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = true;
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $table = 'fa_vs_gift';
|
||||
|
||||
//获取奖池礼物列表
|
||||
public function get_gift_list($gift_bag_id,$room_id)
|
||||
{
|
||||
$box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
||||
$gift_list = [];
|
||||
foreach ($gifts as $key => $value) {
|
||||
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
||||
if($gift_data){
|
||||
$gift_list[$key]['number'] = $key;
|
||||
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
||||
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
||||
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
||||
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
||||
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
}
|
||||
}
|
||||
$ext = json_decode($box['ext'],true);
|
||||
$box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find();
|
||||
|
||||
//巡乐会
|
||||
$is_xlh = 0;
|
||||
$xlh_box = db::name('vs_gift_bag')->where('id',13)->find();
|
||||
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||
$xlh = [];
|
||||
if($xlh_ext['inlet_bag_id'] == $box['id']){
|
||||
$is_xlh = 1;
|
||||
$xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数
|
||||
$xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数
|
||||
//当前抽奖次数
|
||||
$xlh['current_num'] = Cache::get("xlh_periods_num") ?? 0;
|
||||
//状态
|
||||
if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){
|
||||
$xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||
} elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){
|
||||
$xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||
}else{
|
||||
$xlh['status'] = 0;
|
||||
}
|
||||
}
|
||||
$result_data = [
|
||||
'title' => $box['name'],
|
||||
'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"],
|
||||
'box_price' => $box_gift['gift_price'],
|
||||
'is_xlh' => $is_xlh,
|
||||
'xlh_data' => $xlh,
|
||||
'gift_list' => $gift_list,
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data];
|
||||
}
|
||||
|
||||
/*
|
||||
* 礼物特效播放
|
||||
*/
|
||||
public function gift_send($send_id){
|
||||
try{
|
||||
$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];
|
||||
}
|
||||
$room_id = $blind_box_turntable['room_id'];
|
||||
$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'];
|
||||
$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();
|
||||
$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[] = [
|
||||
'text' => $text_message,
|
||||
'gift_picture' => $draw_gift['base_image'],
|
||||
'room_id' => $room_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $draw_gift['gift_name'],
|
||||
'roomId' => $room_id,
|
||||
'number' => $value['count'],
|
||||
];
|
||||
}
|
||||
|
||||
$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']
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$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,
|
||||
'ToUserInfo' => $userInfo,
|
||||
'GiftInfos' => array_values($gifts),
|
||||
'text' => $userTextMessage
|
||||
];
|
||||
|
||||
// 聊天室推送系统消息给每个用户
|
||||
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){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$room_id,$text1);
|
||||
}else{
|
||||
if(!empty($text_list_new)){
|
||||
//推送礼物横幅
|
||||
$push = new Push($blind_box_turntable['user_id'], $room_id);
|
||||
$push->giftBanner($text_list_new);
|
||||
}
|
||||
}
|
||||
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' => "网络请求错误,请重试!".$e->getMessage(), 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取用户抽奖记录
|
||||
*/
|
||||
public function get_user_record($gift_bag_id,$user_id=0,$page=1,$page_size=12){
|
||||
$where = [];
|
||||
$where['b.gift_bag_id'] = $gift_bag_id;
|
||||
if($user_id > 0){
|
||||
$where['b.user_id'] = $user_id;
|
||||
}
|
||||
$list = db('vs_blind_box_turntable_results_log')
|
||||
->alias('a')
|
||||
->join('vs_blind_box_turntable_log b','b.id = a.tid','left')
|
||||
->join('user c','a.gift_user_id = c.id','left')
|
||||
->join('vs_gift d','d.gid = a.gift_id','left')
|
||||
->field('a.gift_id,a.count,a.gift_user_id,a.createtime,c.nickname,d.gift_name as gift_name,d.base_image')
|
||||
->where($where)
|
||||
->order('a.createtime desc')
|
||||
->page($page,$page_size)
|
||||
->select();
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
/*
|
||||
* 获取全服抽奖记录
|
||||
*/
|
||||
public function get_all_record($gift_bag_id,$page=1,$page_size=12){
|
||||
$where = [];
|
||||
$where['b.gift_bag_id'] = $gift_bag_id;
|
||||
$where['d.gift_bag_id'] = $gift_bag_id;
|
||||
$where['d.is_world_show'] = 1;
|
||||
$list = db('vs_blind_box_turntable_results_log')
|
||||
->alias('a')
|
||||
->join('vs_blind_box_turntable_log b','b.id = a.tid','left')
|
||||
->join('user c','b.user_id = c.id','left')
|
||||
->join('vs_gift_bag_detail d','d.foreign_id = a.gift_id','left')
|
||||
->join('vs_gift e','e.gid = a.gift_id','left')
|
||||
->field('a.gift_id,a.count,b.user_id,a.createtime,c.nickname,d.name as gift_name,e.base_image')
|
||||
->where($where)
|
||||
->order('a.createtime desc')
|
||||
->page($page,$page_size)
|
||||
->select();
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
/*
|
||||
* 巡乐会
|
||||
*/
|
||||
public function xlh_gift_list($room_id){
|
||||
$gift_bag_id = 13;
|
||||
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
||||
$gift_list = [];
|
||||
foreach ($gifts as $key => $value) {
|
||||
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
||||
if($gift_data){
|
||||
$gift_list[$key]['number'] = $key;
|
||||
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
||||
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
||||
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
||||
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
||||
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
}
|
||||
}
|
||||
//房主信息
|
||||
// $room_user = db::name('user')->where('id',$room_data['user_id'])->find();
|
||||
//房主礼物
|
||||
$room_user_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['give_homeowner_gift_id'])->find();
|
||||
//巡乐会主礼物
|
||||
$xlh_main_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['locking_gift_id'])->find();
|
||||
//中奖用户
|
||||
$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)){
|
||||
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']){
|
||||
$xlh_user = db::name('user')->where('id',$pan_xlh['user_id'])->find();
|
||||
$xlh_user_data = [
|
||||
'user_id' => $xlh_user['id'],
|
||||
'nickname' => $xlh_user['nickname'],
|
||||
'avatar' => $xlh_user['avatar'],
|
||||
];
|
||||
if($pan_xlh['room_id']){
|
||||
$room_data = db::name('vs_room')->field('xlh_periods,xlh_periods_num,user_id')-> where('id',$pan_xlh['room_id'])->find();
|
||||
$room_user = db::name('user')->where('id',$room_data['user_id'])->find();
|
||||
$room_user_data = [
|
||||
'user_id' => $room_user['id'],
|
||||
'nickname' => $room_user['nickname'],
|
||||
'avatar' => $room_user['avatar'],
|
||||
];
|
||||
}
|
||||
}
|
||||
//$gift_list 按gift_price 升序排序
|
||||
usort($gift_list, function($a, $b) {
|
||||
return $a['gift_price'] - $b['gift_price'];
|
||||
});
|
||||
|
||||
$result_data = [
|
||||
'title' => $xlh_box['name'],
|
||||
'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$xlh_box["id"],
|
||||
'box_price' => $xlh_ext['xlh_box_price'],
|
||||
'xlh_end_time' =>$pan_xlh['end_time']??0,
|
||||
'give_homeowner_gift' => [
|
||||
'gift_id' => $room_user_gift['gid'],
|
||||
'gift_name' => $room_user_gift['gift_name'],
|
||||
'gift_price' => $room_user_gift['gift_price'],
|
||||
'base_image' => $room_user_gift['base_image'],
|
||||
],
|
||||
'homeowner_user' => $room_user_data,
|
||||
'locking_gift' => [
|
||||
'gift_id' => $xlh_main_gift['gid'],
|
||||
'gift_name' => $xlh_main_gift['gift_name'],
|
||||
'gift_price' => $xlh_main_gift['gift_price'],
|
||||
'base_image' => $xlh_main_gift['base_image'],
|
||||
'gift_num' => $pan_xlh['num']??0
|
||||
],
|
||||
'xlh_user' => $xlh_user_data,
|
||||
'gift_list' => $gift_list,
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data];
|
||||
}
|
||||
|
||||
/*
|
||||
* 巡乐会抽奖记录
|
||||
*/
|
||||
public function xlh_get_user_record($user_id,$room_id,$page=1,$page_size=12){
|
||||
$where = [];
|
||||
$where['a.gift_bag_id'] = 13;
|
||||
$where['a.user_id'] = $user_id;
|
||||
$list = db('vs_gift_bag_receive_pan_log')
|
||||
->alias('a')
|
||||
->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
|
||||
->join('vs_gift c','c.gid = a.gift_id','left')
|
||||
->field('a.gift_id,a.num as count,a.createtime,c.gift_name as gift_name,c.base_image')
|
||||
->where($where)
|
||||
->order('a.createtime desc')
|
||||
->page($page,$page_size)
|
||||
->select();
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
|
||||
/*
|
||||
* 巡乐会榜单
|
||||
*/
|
||||
public function xlh_ranking($room_id,$page=1,$page_size=12){
|
||||
$where = [];
|
||||
$where['a.gift_bag_id'] = 13;
|
||||
$where['e.is_world_show'] = 1;
|
||||
$list = db('vs_gift_bag_receive_pan_log')
|
||||
->alias('a')
|
||||
->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
|
||||
->join('vs_gift c','c.gid = a.gift_id','left')
|
||||
->join('fa_user d','d.id = a.user_id','left')
|
||||
->join('vs_gift_bag_detail e','e.foreign_id = a.gift_id','left')
|
||||
->field('a.gift_id,a.num as count,a.createtime,c.gift_name,c.base_image,d.nickname')
|
||||
->where($where)
|
||||
->order('a.createtime desc')
|
||||
->page($page,$page_size)
|
||||
->select();
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取用户当前房间的巡乐会信息
|
||||
*/
|
||||
public function get_user_xlh_info($room_id){
|
||||
$gift_bag_id = 13;
|
||||
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||
$xlh_data = db('vs_room_pan_xlh')->where(["send_time"=>0,"end_time"=>[">",time()]])->field('id,room_id,periods,end_time')->order('periods desc')->find();
|
||||
//寻乐会状态
|
||||
$xlh_status = 0;
|
||||
// 状态
|
||||
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
|
||||
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
||||
$xlh_status = 1;//状态 1:巡乐会开始 2:即将开始 0:等待开始
|
||||
} elseif($xlh_periods_num >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh_periods_num < $xlh_ext['open_condition']['start_num']){
|
||||
$xlh_status = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||
}else{
|
||||
$xlh_status = 0;//未开始
|
||||
}
|
||||
return [
|
||||
'activities_name' => $xlh_box['name'],
|
||||
'icon' => null,
|
||||
'xlh_status'=>$xlh_status,
|
||||
'end_time'=>$xlh_data['end_time'] ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
* 巡乐会榜单
|
||||
*
|
||||
*/
|
||||
public function xlh_ranking_list($room_id,$page=1,$page_size=12){
|
||||
$gift_bag_id = 13;
|
||||
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||
$pan_xlh = db::name('vs_room_pan_xlh')
|
||||
->order('id desc')
|
||||
->page($page,$page_size)
|
||||
->select();
|
||||
$list = [];
|
||||
foreach ($pan_xlh as $key=>$value){
|
||||
$list[$key]['periods'] = "第".$value['periods']."期";
|
||||
if(!empty($value['user_id'])){
|
||||
$list[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
}else{
|
||||
$list[$key]['nickname'] = "无";
|
||||
}
|
||||
if(!empty($value['gift_id'])){
|
||||
$gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$value['gift_id']])->find();
|
||||
$list[$key]['gift_name'] = 'x '.$value['num'].' '.$gift_data['gift_name'];
|
||||
$list[$key]['base_image'] = $gift_data['base_image']??"";
|
||||
}else{
|
||||
$gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$xlh_ext['locking_condition']['locking_gift_id']])->find();
|
||||
$list[$key]['gift_name'] = 'x 0 '.$gift_data['gift_name'];
|
||||
$list[$key]['base_image'] = $gift_data['base_image']??"";
|
||||
}
|
||||
$list[$key]['createtime'] = $value['send_time'] ? date('Y-m-d H:i:s',$value['send_time']) : '' ;
|
||||
}
|
||||
return [
|
||||
'code' => 1,
|
||||
'msg' => '成功',
|
||||
'data' => $list
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
1603
application/api/model/BlindBoxTurntableGiftDraw.php
Normal file
1603
application/api/model/BlindBoxTurntableGiftDraw.php
Normal file
File diff suppressed because it is too large
Load Diff
1547
application/api/model/BlindBoxTurntableGiftDrawWorld.php
Normal file
1547
application/api/model/BlindBoxTurntableGiftDrawWorld.php
Normal file
File diff suppressed because it is too large
Load Diff
1408
application/api/model/BlindBoxTurntableGiftDrawWorldNew.php
Normal file
1408
application/api/model/BlindBoxTurntableGiftDrawWorldNew.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -89,6 +89,63 @@ class Chat extends Model
|
||||
// RoomAuctionPK = 1037,
|
||||
//送盲盒礼物推送文字消息
|
||||
// RoomGiftBlindBox = 1038,
|
||||
//换麦
|
||||
// RoomChangePit = 1039,
|
||||
|
||||
//交友房间内发送消息
|
||||
//交友房游戏阶段
|
||||
// FriendRoomGameStart = 1049,
|
||||
//交友房延时
|
||||
// FriendRoomDelay = 1050,
|
||||
//交友结束推送是否创建小房间
|
||||
// FriendRoomEnd = 1051,
|
||||
//交友房 私密小屋送礼增加结束时间
|
||||
// FriendRoomGiftBlindBox = 1052,
|
||||
//交友 房间换麦位
|
||||
// FriendRoomChangePit = 1053,
|
||||
//交友 心动值变化
|
||||
// FriendRoomChangeCharm = 1054,
|
||||
//交友 退出小房间
|
||||
// FriendRoomQuit = 1055,
|
||||
|
||||
//盲盒转盘相关推送
|
||||
//巡乐会进度推送
|
||||
// BlindBoxTurnTableProgress = 1056,
|
||||
//巡乐会抽奖结果推送
|
||||
// BlindBoxTurnTableResult = 1057,
|
||||
|
||||
//直播群成员在离线状态变更
|
||||
// RoomMemberOffline = 1058,
|
||||
|
||||
//清空个人魅力
|
||||
// ClearUserCharm = 1059,
|
||||
//发红包
|
||||
// RedPacket = 1060,
|
||||
//红包领完推送
|
||||
// RedPacketComplete = 1061,
|
||||
|
||||
//点歌房推送信息
|
||||
//当前歌曲发生变化
|
||||
// SongChange = 1070,
|
||||
//下一首歌曲发生变化
|
||||
// SongNextChange = 1071,
|
||||
//歌曲数量发生变化
|
||||
// SongCountChange = 1072,
|
||||
|
||||
//CP房间推送信息
|
||||
// CP进入房间触发特效
|
||||
// CPRoomEffect = 1080,
|
||||
|
||||
//签约房推送信息
|
||||
//开始签约
|
||||
// SignRoomStart = 1090,
|
||||
//签约房签约出价最高用户
|
||||
// SignRoomSignUser = 1091,
|
||||
//签约房间结束
|
||||
// SignRoomEnd = 1092,
|
||||
//签约延时
|
||||
// SignRoomDelay = 1093,
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +155,7 @@ class Chat extends Model
|
||||
'Text' => $content
|
||||
];
|
||||
|
||||
$data = model('Tencent')->send_group_system_notification('room'.$roomId,json_encode($text));
|
||||
$data = model('api/Tencent')->send_group_system_notification('room'.$roomId,json_encode($text));
|
||||
|
||||
if($data['code'] == 0){
|
||||
Log::record("腾讯发送群消息:".$data['msg'].$type,"info");
|
||||
|
||||
@@ -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,19 +146,28 @@ 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])){
|
||||
$v['processing_type'] = 2;
|
||||
$v['processing_type_str'] = $this->processing_type_str[$v['processing_type']];
|
||||
//跳转的房间路径
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6]])->orderRaw('rand()')->value('id');
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6],'apply_status'=>2])->orderRaw('rand()')->value('id');
|
||||
$v['target_quantity'] = $v['target_quantity'] * 60;
|
||||
$v['is_time'] = 1;
|
||||
}elseif(in_array($v['task_id'],[10])){
|
||||
$v['processing_type'] = 7;
|
||||
$v['processing_type_str'] = $this->processing_type_str[$v['processing_type']];
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6]])->orderRaw('rand()')->value('id');
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6],'apply_status'=>2])->orderRaw('rand()')->value('id');
|
||||
} else{
|
||||
$v['processing_type'] = 9;
|
||||
$v['processing_type_str'] = $this->processing_type_str[$v['processing_type']];
|
||||
@@ -152,10 +178,11 @@ 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];
|
||||
}
|
||||
@@ -220,41 +247,81 @@ class DailyTasks extends Model
|
||||
|
||||
//领取每日任务金币奖励
|
||||
public function daily_tasks_receive($user_id,$task_id){
|
||||
//查询是否实名认证
|
||||
$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_info['task_type']==3){
|
||||
$user_daily_tasks = Db::name('vs_user_daily_tasks')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
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];
|
||||
}
|
||||
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];
|
||||
}
|
||||
}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];
|
||||
}
|
||||
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];
|
||||
//师徒任务
|
||||
//师傅签约返还
|
||||
$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 {
|
||||
$reslut = Db::name('vs_user_daily_tasks')->where('id',$user_daily_tasks['id'])->update([
|
||||
'is_claimed' => 1,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
if ($reslut) {
|
||||
//操作用户金币
|
||||
$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) {
|
||||
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(),
|
||||
]);
|
||||
if ($reslut) {
|
||||
//操作用户金币
|
||||
$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' => $res['msg'], 'data' => null];
|
||||
}
|
||||
} else {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
} else {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
@@ -342,10 +409,10 @@ class DailyTasks extends Model
|
||||
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,de.name as gift_name,re.createtime as createtime,de.quantity,de.type,de.foreign_id,de.days,de.gold')
|
||||
->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.gift_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();
|
||||
|
||||
@@ -15,9 +15,9 @@ 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=>'财富等级特权赠送'];
|
||||
// 定义字段类型 1头像框 2坐骑 3麦圈 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=>'爵位购买赠送'];
|
||||
public function __construct($data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
@@ -27,6 +27,7 @@ class Decorate extends Model
|
||||
//获取装扮类型
|
||||
public function get_type_list($have_hot = 0)
|
||||
{
|
||||
$no_show_ids = [6,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 +35,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 +75,19 @@ class Decorate extends Model
|
||||
'a.type' => $type,
|
||||
];
|
||||
}
|
||||
$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();
|
||||
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,19 +102,25 @@ class Decorate extends Model
|
||||
if (!$decorate) {
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['did' => $did, 'is_delete' => 1])->order('day asc')->select();
|
||||
if (!$decorate_price) {
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
$result['title'] = $decorate['title'];
|
||||
foreach ($decorate_price as $k => $v) {
|
||||
$result['price_list'][$k]['price'] = (int)$v['price'];
|
||||
$result['price_list'][$k]['discount'] = $v['discount'];
|
||||
$result['price_list'][$k]['day'] = $v['day'];
|
||||
//月
|
||||
$result['price_list'][$k]['month'] = $v['day']/30;
|
||||
//有效期至
|
||||
$result['price_list'][$k]['end_time'] = date('Y-m-d',strtotime("+".$v['day']." day"));
|
||||
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' => '参数错误'];
|
||||
}
|
||||
$result['title'] = $decorate['title'];
|
||||
foreach ($decorate_price as $k => $v) {
|
||||
$result['price_list'][$k]['price'] = (int)$v['price'];
|
||||
$result['price_list'][$k]['discount'] = $v['discount'];
|
||||
$result['price_list'][$k]['day'] = $v['day'];
|
||||
//月
|
||||
$result['price_list'][$k]['month'] = $v['day']/30;
|
||||
//有效期至
|
||||
$result['price_list'][$k]['end_time'] = date('Y-m-d',strtotime("+".$v['day']." day"));
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $result];
|
||||
}
|
||||
@@ -113,7 +135,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];
|
||||
}
|
||||
@@ -125,32 +147,38 @@ class Decorate extends Model
|
||||
$map = [];
|
||||
$map = [
|
||||
'did' => $did,
|
||||
'is_buy' => 1,
|
||||
'delete_time' => 0,
|
||||
];
|
||||
$decorate_info = DB::name($this->table)->where($map)->find();
|
||||
if(!$decorate_info){
|
||||
return ['code' => 0, 'msg' => '该装扮不存在'.$did, 'data' => null];
|
||||
}
|
||||
//该天数是否存在
|
||||
$map = [];
|
||||
$map = [
|
||||
'did' => $did,
|
||||
'day' => $day,
|
||||
'is_delete' => 1,
|
||||
];
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where($map)->find();
|
||||
if(!$decorate_price_info){
|
||||
return ['code' => 0, 'msg' => '该装扮天数不存在', 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] == 6 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该个人靓号已被购买', 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] == 7 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该房间靓号已被购买', 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] == 8 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该工会靓号已被购买', 'data' => null];
|
||||
if($decorate_info['type'] != 12){
|
||||
//该天数是否存在
|
||||
$map = [];
|
||||
$map = [
|
||||
'did' => $did,
|
||||
'day' => $day,
|
||||
'is_delete' => 1,
|
||||
];
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where($map)->find();
|
||||
if(!$decorate_price_info){
|
||||
return ['code' => 0, 'msg' => '该装扮天数不存在', 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] == 6 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该个人靓号已被购买', 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] == 7 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该房间靓号已被购买', 'data' => null];
|
||||
}
|
||||
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();
|
||||
@@ -194,24 +222,36 @@ 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'] ?? '';
|
||||
$result = db::name('vs_user_decorate')->insert($data);
|
||||
}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($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;
|
||||
}
|
||||
$change_time = $day * 24 * 3600;
|
||||
$update['is_using'] = 2;
|
||||
$update['end_time'] = $user_decorate_data['end_time'] + $change_time;
|
||||
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update($update);
|
||||
$start_time = $update['end_time'];
|
||||
}
|
||||
$change_time = $day * 24 * 3600;
|
||||
$update['is_using'] = 2;
|
||||
$update['end_time'] = $user_decorate_data['end_time'] + $change_time;
|
||||
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update($update);
|
||||
$start_time = $update['end_time'];
|
||||
}
|
||||
}
|
||||
if(!$result){
|
||||
@@ -256,24 +296,33 @@ class Decorate extends Model
|
||||
|
||||
//用户装扮列表
|
||||
public function user_decorate($uid, $type,$page=1, $limit=10){
|
||||
|
||||
$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')
|
||||
->where('ud.user_id', $uid)
|
||||
->where('ud.type', $type)
|
||||
->where(['ud.end_time'=>[">=",time()]])
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
foreach($reslut as $k => &$v){
|
||||
$remaining_day = ceil(($v['end_time'] - time())/86400);
|
||||
if($remaining_day <= 0){
|
||||
$remaining_day = 0;
|
||||
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')
|
||||
->where('ud.user_id', $uid)
|
||||
->where('ud.type', $type)
|
||||
->where(['ud.end_time'=>[">=",time()]])
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
foreach($reslut as $k => &$v){
|
||||
$remaining_day = ceil(($v['end_time'] - time())/86400);
|
||||
if($remaining_day <= 0){
|
||||
$remaining_day = 0;
|
||||
}
|
||||
//剩余天数 取整
|
||||
$v['remaining_day'] = $v['is_perpetual']==1 ? '永久' :$remaining_day;
|
||||
$v['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
|
||||
}
|
||||
//剩余天数 取整
|
||||
$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];
|
||||
}
|
||||
@@ -290,10 +339,15 @@ class Decorate extends Model
|
||||
if (empty($info)) {
|
||||
return ['code' => 0, 'msg' => '装扮不存在', 'data' => null];
|
||||
}
|
||||
if ($info['end_time'] < time()) {
|
||||
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 {
|
||||
//清理该类型装扮使用状态
|
||||
@@ -318,6 +372,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();
|
||||
@@ -325,19 +382,46 @@ class Decorate extends Model
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
//推送信息去所在房间
|
||||
//查询当前所在房间
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $uid])->order('id' , 'desc')->value('room_id');
|
||||
if($room_id){
|
||||
//当前用户信息
|
||||
//推送信息
|
||||
$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']['chat_dress'] = model('Decorate')->user_decorate_detail($uid,5);
|
||||
$text['text'] = '用户 ' . $text['FromUserInfo']['nickname'] .' 修改了信息';
|
||||
model('Chat')->sendMsg(1035,$room_id,$text,$uid);
|
||||
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');
|
||||
if($room_id){
|
||||
//当前用户信息
|
||||
//推送信息
|
||||
$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_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);
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => "设置成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
@@ -361,60 +445,78 @@ class Decorate extends Model
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => "取消装扮失败", 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => "取消成功", 'data' => null];
|
||||
}
|
||||
|
||||
//用户装扮详情
|
||||
/*
|
||||
* @param $id 对象id
|
||||
* @param $type 装扮类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8工会靓号
|
||||
* @param $type 装扮类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
168
application/api/model/Family.php
Normal file
168
application/api/model/Family.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
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);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $user_id,'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$myFamily['group_owner_info']['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'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()]])
|
||||
->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']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $v['user_id'],'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$lists[$k]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'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;
|
||||
}
|
||||
if($v['createtime'] > strtotime(date('Y-m-d'))){
|
||||
$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',[strtotime(date('Y-m-d')),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);//今日收益
|
||||
}
|
||||
if($v['createtime'] >= strtotime(date('Y-m-d'))) {
|
||||
//昨日收益
|
||||
$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', [strtotime(date('Y-m-d', strtotime('-1 day'))), strtotime(date('Y-m-d'))]]])
|
||||
->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];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
801
application/api/model/Friend.php
Normal file
801
application/api/model/Friend.php
Normal file
@@ -0,0 +1,801 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class Friend extends Model
|
||||
{
|
||||
public function start_friend($user_id, $room_id){
|
||||
// 判断用户是否在主持麦
|
||||
$host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find();
|
||||
if(!$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
|
||||
$room_info = db::name('vs_room')->field('id,step,room_status')->where(['id' => $room_id,'room_status' =>1])->find();
|
||||
if (!$room_info) {
|
||||
return ['code' => 0, 'msg' => '房间不存在!', 'data' => null];
|
||||
}
|
||||
if($room_info['step'] == 2 || $room_info['step'] == 3){
|
||||
return ['code' => 0, 'msg' => '交友正在进行中!', 'data' => null];
|
||||
}
|
||||
//在麦位上的用户
|
||||
$pit_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->count();
|
||||
|
||||
if($pit_user >= 2) {
|
||||
$data['room_id'] = $room_id;
|
||||
$data['end_time'] = time() + get_system_config_value('friend_time') * 60;
|
||||
$data['create_time'] = time();
|
||||
$data['status'] = 1;
|
||||
|
||||
$id = db::name('vs_user_friending')->insertGetId($data);
|
||||
|
||||
if (!$id) {
|
||||
return ['code' => 0, 'msg' => '操作失败!', 'data' => null];
|
||||
}
|
||||
//修改房间状态
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['step' => 2]);
|
||||
//清除房间用户的魅力
|
||||
model('Room')->clear_user_charm($user_id, $room_id);
|
||||
|
||||
//推送给前端消息
|
||||
$text['text'] = '交友开始';
|
||||
$text['step'] = 2;
|
||||
$text['friend_id'] = $id;
|
||||
$text['end_time'] = $data['end_time'];
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => ['friend_id' => $id]];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '交友麦位至少两位用户才能开始', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//延时
|
||||
public function delay($user_id,$room_id,$id,$delay_times){
|
||||
// 判断用户是否在主持麦
|
||||
$host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find();
|
||||
if(!$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
|
||||
if (!$id || !$room_id) {
|
||||
return ['code' => 0, 'msg' => '参数有误!', 'data' => null];
|
||||
}
|
||||
if($delay_times <= 0){
|
||||
$delay_times = get_system_config_value('friend_delay_times');
|
||||
}
|
||||
//修改结束 时间
|
||||
$res = db::name('vs_user_friending')->where('id', $id)->update([
|
||||
'end_time' => Db::raw('end_time + ' . ($delay_times * 60))
|
||||
]);
|
||||
if(!$res){
|
||||
return ['code' => 0, 'msg' => '操作失败!', 'data' => null];
|
||||
}
|
||||
//推送延时
|
||||
$text['text'] = '延时';
|
||||
$text['friend_id'] = $id;
|
||||
$text['end_time'] = db::name('vs_user_friending')->where('id', $id)->value('end_time');
|
||||
model('api/Chat')->sendMsg(1050,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => null];
|
||||
}
|
||||
|
||||
//交友结束(结束牵手良缘)
|
||||
public function end_friend($user_id,$room_id,$id,$is_system = 0){
|
||||
if (!$id || !$room_id) {
|
||||
return ['code' => 0, 'msg' => '参数有误!', 'data' => null];
|
||||
}
|
||||
|
||||
if($is_system == 0){
|
||||
// 判断用户是否在主持麦
|
||||
$host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find();
|
||||
if(!$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
// 获取心动值最高的
|
||||
$originalPairs = db::name('vs_user_friending_heart')
|
||||
->where(['room_id'=>$room_id,'friend_id'=>$id ,'status' =>1])
|
||||
->order('heart_value DESC')->find();
|
||||
$friend_heart_value = get_system_config_value('friend_heart_value');
|
||||
if($originalPairs && $originalPairs['heart_value'] >= $friend_heart_value){
|
||||
$step = 3;//结束进入牵手良缘卡关系
|
||||
//心动值达到伐值 返回用户信息与关系列表
|
||||
$return['user1_id'] =$originalPairs['user1_id'];
|
||||
$return['user1_avatar'] = db::name('user')->where(['id'=>$originalPairs['user1_id']])->value('avatar');
|
||||
$return['user1_nickname'] = db::name('user')->where(['id'=>$originalPairs['user1_id']])->value('nickname');
|
||||
$return['user2_id'] =$originalPairs['user2_id'];
|
||||
$return['user2_avatar'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('avatar');
|
||||
$return['user2_nickname'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('nickname');
|
||||
$return['heart_value'] = $originalPairs['heart_value'];
|
||||
$return['heart_id'] = $originalPairs['id'];
|
||||
$room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime');
|
||||
if($room_updatatime){ //60秒内没操作 则创建关系无
|
||||
if(time() - $room_updatatime > 60){
|
||||
$this->createRelation(0,$room_id,$id,$return['user1_id'],$return['user2_id'],0);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||
}
|
||||
}else{
|
||||
// 修改当前交友阶段
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['step' => $step,'updatetime' => time()]);
|
||||
}
|
||||
}else{
|
||||
$step = 1;//结束下一轮
|
||||
// 修改当前交友阶段 分开写 放到前面是为了下麦
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
//所有人下麦
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
$return = null;
|
||||
}
|
||||
|
||||
//结束交友游戏
|
||||
if($step == 1){
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2]);
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = $step == 1 ? '交友结束' : '牵手良缘';
|
||||
$text['step'] = $step;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||
$text['friend_user'] = $return;
|
||||
$text['friend_id'] = $id;
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
model('Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||
}
|
||||
|
||||
//心动值超过配置值 创建关系
|
||||
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];
|
||||
}
|
||||
|
||||
$user1 = min($user1_id, $user2_id);
|
||||
$user2 = max($user1_id, $user2_id);
|
||||
$friending_heart = db::name('vs_user_friending_heart')
|
||||
->where(['room_id'=>$room_id,'friend_id'=>$friend_id ,'user1_id' =>$user1,'user2_id' => $user2])->order('id desc')->find();
|
||||
|
||||
$originalPairs = db::name('vs_user_friending_heart')
|
||||
->where(['id'=>$friending_heart['id']])
|
||||
->update(['status' => 3,'friend_config_id' =>$friending_config_id]);
|
||||
$msg = '';
|
||||
if ($originalPairs) {
|
||||
$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){
|
||||
//创建小房间
|
||||
$room_ids = model('api/Room')->user_create_room($user1,'的电影房',get_system_config_value('web_site').'/data/avatar/head_pic.png','交友房产生的一次性房间',7);
|
||||
if($room_ids['code'] != 1){
|
||||
$msg = 'cp电影房创建失败';
|
||||
}else{
|
||||
//记录小房间
|
||||
$datda = [
|
||||
'room_id' => $room_ids['data'],
|
||||
'relation_id' => $friending_config_id,
|
||||
'user_id' => $user1,
|
||||
'user_id1' => $user2,
|
||||
'time_day' => time() + get_system_config_value('friend_room_timea') * 60,
|
||||
'createtime' => time(),
|
||||
'status' => 1,
|
||||
'type' => 1
|
||||
];
|
||||
db::name('vs_room_cp_movie')->insert($datda);
|
||||
|
||||
if($room_ids['data']){
|
||||
$text['text'] = '交友结束并创建房间';
|
||||
$text['room_id'] = $room_ids['data'];//前端用来让用户跳转的房间id
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$text['text'] = '交友结束未创建房间';
|
||||
}
|
||||
$text['relation_name'] = $relation;
|
||||
$text['user1_id'] = $user1;
|
||||
$text['user2_id'] = $user2;
|
||||
$text['user1_avatar'] = db::name('user')->where(['id'=>$user1])->value('avatar');
|
||||
$text['user1_nickname'] = db::name('user')->where(['id'=>$user1])->value('nickname');
|
||||
$text['user2_avatar'] = db::name('user')->where(['id'=>$user2])->value('avatar');
|
||||
$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;
|
||||
|
||||
//更新关系结束时间
|
||||
db::name('vs_user_friending_heart')->where(['id'=>$friending_heart['id']])->update(['contact_end_time' => $friendendtime]);
|
||||
|
||||
//关系增加时间
|
||||
$room_auction = model('RoomAuction')->room_auction_create_or_add($user1_id,$user2_id,$friending_config_id,$shijian*3600,0);
|
||||
|
||||
//推送给前端消息
|
||||
$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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//退出私密房间
|
||||
public function outRoom($user_id,$room_id){
|
||||
//推送给前端消息
|
||||
$text['text'] = '退出私密小屋';
|
||||
model('api/Chat')->sendMsg(1055,$room_id,$text);
|
||||
|
||||
|
||||
// //查询在房间的用户
|
||||
// $users = db::name('vs_room_visitor')->where(['room_id'=>$room_id])->select();
|
||||
// if($users){
|
||||
// //退出房间
|
||||
// foreach ($users as $v){
|
||||
// //退出房间
|
||||
// model('Room')->quit_room($v['user_id'], $room_id,$v['user_id']);
|
||||
// }
|
||||
// }else{
|
||||
// model('Room')->quit_room($user_id, $room_id,$user_id);
|
||||
// }
|
||||
|
||||
//注销房间
|
||||
db::name('vs_room')->where(['id'=>$room_id])->update(['room_status'=>3]);
|
||||
db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]);
|
||||
model('api/Tencent')->delete_group('room'.$room_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '退出成功!', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//房间内送礼
|
||||
/*
|
||||
* @param $uid 用户id
|
||||
* @param $to_uid 接收用户id组
|
||||
* @param $gift_id 礼物id
|
||||
* @param $gift_num 礼物数量
|
||||
* @param $from_type 来源 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
* @param $type 1金币购买 2送背包礼物
|
||||
* @param $room_id 房间id
|
||||
* @param $pit_number 坑位
|
||||
*/
|
||||
public function room_give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number, $heart_id,$give_gift_ext)
|
||||
{
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number,0,$give_gift_ext);
|
||||
if($res['code'] != 1){
|
||||
return $res;
|
||||
}
|
||||
|
||||
//送礼成功后续操作
|
||||
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
|
||||
$friend = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id desc')->find();
|
||||
if($friend && time() >= $friend['create_time'] && time() <= $friend['end_time']){
|
||||
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
|
||||
$sumPrice = $res['data']['gift_total'] * $heart_exp;
|
||||
$user_idd = $to_uid;
|
||||
|
||||
if($heart_id){//有这个值就是助力 不参加抢麦操作
|
||||
db::name('vs_user_friending_heart')->where(['id' => $heart_id])->setInc('heart_value', $sumPrice);
|
||||
$this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知
|
||||
//生成新排名 判断抱上麦 还是换麦
|
||||
$this->pullUserPit($room_id,$friend['id']);
|
||||
}else{
|
||||
//判断送礼人或收礼人里面有主持和嘉宾
|
||||
$host = $this->is_host($uid,$to_uid,$room_id);
|
||||
$user_idd = explode(",", $user_idd); // 将字符串转换为数组
|
||||
//判断是否是主持
|
||||
if($host['is_preside'] == 1){
|
||||
if(!in_array($uid,$host['is_preside_user'])){//主持不是当前送礼人,那就是在收礼人中
|
||||
//从数组中剔除主持人 && $is_preside_user!= UID
|
||||
$user_idd = array_diff($user_idd, $host['is_preside_user']); // 从数组中移除
|
||||
if($user_idd){
|
||||
//插入/更新心动表
|
||||
$this->addUserHeart($uid,$user_idd,$friend['id'],$sumPrice,$room_id,$res['data']['gift_user_data']);
|
||||
//送礼产生心动值并计算 判断拉取用户上麦还是换麦
|
||||
//生成新排名 判断抱上麦 还是换麦
|
||||
$this->pullUserPit($room_id,$friend['id']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//插入/更新心动表
|
||||
$this->addUserHeart($uid,$user_idd,$friend['id'],$sumPrice,$room_id,$res['data']['gift_user_data']);
|
||||
//送礼产生心动值并计算 判断拉取用户上麦还是换麦
|
||||
//生成新排名 判断抱上麦 还是换麦
|
||||
$this->pullUserPit($room_id,$friend['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => $res['data']];
|
||||
}
|
||||
|
||||
//是否主持
|
||||
public function is_host($uid,$to_uid,$room_id){
|
||||
//获取当前主持人和嘉宾
|
||||
$host[] = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 9])->value('user_id');
|
||||
$host[] = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 10])->value('user_id');
|
||||
|
||||
$is_preside_user = [];
|
||||
$is_preside = 0;
|
||||
$user_ids = explode(",", $to_uid);
|
||||
foreach ($user_ids as $value) {
|
||||
//判断收礼人是否是主持
|
||||
if (in_array($value, $host)) {
|
||||
$is_preside = 1;
|
||||
$is_preside_user[] = $value;
|
||||
}
|
||||
}
|
||||
//送礼人是主持或嘉宾
|
||||
if (in_array($uid, $host)) {
|
||||
$is_preside = 1;
|
||||
$is_preside_user[] = $uid;
|
||||
}
|
||||
return ['is_preside' =>$is_preside,'is_preside_user' => $is_preside_user];
|
||||
}
|
||||
|
||||
function pullHeartChange($room_id,$friend_id){
|
||||
//聊天室心动值变化通知
|
||||
$newRanking = $this->getRanking($room_id,$friend_id);
|
||||
//心动值和心动表id
|
||||
if(!isset($newRanking[0]['heart_value']) || $newRanking[0]['heart_value'] <= 0){
|
||||
$heart1 = -1;
|
||||
$heartId1 = -1;
|
||||
}else{
|
||||
$heart1 = $newRanking[0]['heart_value'];
|
||||
$heartId1 = $newRanking[0]['id'];
|
||||
}
|
||||
if(!isset($newRanking[1]['heart_value']) || $newRanking[1]['heart_value'] <= 0){
|
||||
$heart2 = -1;
|
||||
$heartId2 = -1;
|
||||
}else{
|
||||
$heart2 = $newRanking[1]['heart_value'];
|
||||
$heartId2 = $newRanking[1]['id'];
|
||||
}
|
||||
if(!isset($newRanking[2]['heart_value']) || $newRanking[2]['heart_value'] <= 0){
|
||||
$heart3 = -1;
|
||||
$heartId3 = -1;
|
||||
}else{
|
||||
$heart3 = $newRanking[2]['heart_value'];
|
||||
$heartId3 = $newRanking[2]['id'];
|
||||
}
|
||||
$heart[0] = [
|
||||
"heartNum" => $heart1,
|
||||
"heartId" => $heartId1,
|
||||
];
|
||||
$heart[1] = [
|
||||
"heartNum" => $heart2,
|
||||
"heartId" => $heartId2,
|
||||
];
|
||||
$heart[2] = [
|
||||
"heartNum" => $heart3,
|
||||
"heartId" => $heartId3,
|
||||
];
|
||||
|
||||
// $push = new Push(0, $this->room_id); //实例化推送类
|
||||
// $push->heartChatRoom($heart);
|
||||
//推送给前端消息
|
||||
$text['text'] = '心动值变化通知';
|
||||
$text['list'] = $heart;
|
||||
model('api/Chat')->sendMsg(1054,$room_id,$text);
|
||||
return $heart;
|
||||
}
|
||||
|
||||
// 获取心跳值排行
|
||||
public function getRanking($room_id,$friend_id) {
|
||||
// 获取有心动值的用户对且不重复
|
||||
$originalPairs = db::name('vs_user_friending_heart')
|
||||
->where(['room_id'=>$room_id,'friend_id'=>$friend_id])
|
||||
->order('heart_value DESC')->select();
|
||||
// 初始化排名数组和已使用用户数组
|
||||
$ranking = [];
|
||||
$usedUsers = [];
|
||||
// 优先选择高价值且无重复用户的对
|
||||
$heart_ids = [];
|
||||
foreach ($originalPairs as &$rel) {
|
||||
// 检查当前用户对是否包含已使用的用户ID
|
||||
if (!in_array($rel['user1_id'], $usedUsers) &&
|
||||
!in_array($rel['user2_id'], $usedUsers)) {
|
||||
// 将符合条件的用户对添加到排名列表中
|
||||
$ranking[] = [
|
||||
'heart_value' => $rel['heart_value'],
|
||||
'id' => $rel['id'],
|
||||
'user1_id' => $rel['user1_id'],
|
||||
'user2_id' => $rel['user2_id'],
|
||||
];
|
||||
// 更新已使用用户列表
|
||||
$usedUsers = array_merge($usedUsers, [$rel['user1_id'], $rel['user2_id']]);
|
||||
$heart_ids[] = $rel['id'];
|
||||
// 如果排名列表达到3对用户,则停止循环
|
||||
if (count($ranking) >= 3) break;
|
||||
}
|
||||
}
|
||||
$ranking1 = [];
|
||||
$ranking2 = [];
|
||||
if(count($ranking)<3){
|
||||
$make_up_num = 3 - count($ranking);
|
||||
$ranking_make_up = db::name('vs_user_friending_heart')
|
||||
->where(['room_id'=>$room_id,'friend_id'=>$friend_id ,'id'=> ['notin',$heart_ids]])
|
||||
->limit($make_up_num)
|
||||
->order('heart_value DESC')->select();
|
||||
foreach ($ranking_make_up as $rel1) {
|
||||
// 如果两个用户都已使用,跳过这条记录
|
||||
if(in_array($rel1['user1_id'], $usedUsers) && in_array($rel1['user2_id'], $usedUsers)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果只有user1已使用,将user2加入排名
|
||||
if(in_array($rel1['user1_id'], $usedUsers)){
|
||||
$ranking1[] = [
|
||||
'heart_value' => 0,
|
||||
'id' => $rel1['id'],
|
||||
'user1_id' => -1,
|
||||
'user2_id' => $rel1['user2_id'],
|
||||
];
|
||||
$usedUsers[] = $rel1['user2_id'];
|
||||
$heart_ids[] = $rel1['id'];
|
||||
}
|
||||
// 如果只有user2已使用,将user1加入排名
|
||||
elseif(in_array($rel1['user2_id'], $usedUsers)){
|
||||
$ranking1[] = [
|
||||
'heart_value' => 0,
|
||||
'id' => $rel1['id'],
|
||||
'user1_id' => $rel1['user1_id'],
|
||||
'user2_id' => -1,
|
||||
];
|
||||
$usedUsers[] = $rel1['user1_id'];
|
||||
$heart_ids[] = $rel1['id'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 返回最终的排名列表
|
||||
$ranking_rut = array_merge($ranking, $ranking1);
|
||||
$nnum = count($ranking)*2 + count($ranking1);
|
||||
if($nnum<6){
|
||||
$make_up_num = 6 - $nnum;
|
||||
$ranking_make_up = db::name('vs_user_friending_heart')
|
||||
->where(array('room_id'=>$room_id,'friend_id'=>$friend_id ,'id'=>array('notin',$heart_ids)))
|
||||
->limit($make_up_num)
|
||||
->order('heart_value DESC')->select();
|
||||
if($ranking_make_up){
|
||||
foreach ($ranking_make_up as $rel1) {
|
||||
if(in_array($rel1['user1_id'], $usedUsers) && in_array($rel1['user2_id'], $usedUsers)){
|
||||
continue;
|
||||
}
|
||||
if(in_array($rel1['user1_id'], $usedUsers)){
|
||||
$ranking2[] = [
|
||||
'heart_value' => 0,
|
||||
'id' => $rel1['id'],
|
||||
'user1_id' => -1,
|
||||
'user2_id' => $rel1['user2_id'],
|
||||
];
|
||||
$usedUsers[] = $rel1['user2_id'];
|
||||
}
|
||||
if(in_array($rel1['user2_id'], $usedUsers)){
|
||||
$ranking2[] = [
|
||||
'heart_value' => 0,
|
||||
'id' => $rel1['id'],
|
||||
'user1_id' => $rel1['user1_id'],
|
||||
'user2_id' => -1,
|
||||
];
|
||||
$usedUsers[] = $rel1['user1_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return array_merge($ranking_rut, $ranking2);
|
||||
}
|
||||
|
||||
|
||||
//抱上麦 还是换麦
|
||||
public function pullUserPit($room_id,$friend_id){
|
||||
$friendPlayPit = $this->friendPlayPit($room_id,$friend_id); // 获取实际应该对应的麦位
|
||||
$this->changePitToPosPair($room_id,$friendPlayPit);//换麦,上下麦
|
||||
$this->pullHeartChange($room_id,$friend_id);//聊天室心动值变化通知
|
||||
}
|
||||
|
||||
//交友处理麦位排名
|
||||
public function friendPlayPit($room_id,$friend_id){
|
||||
//查询当前交友心动值表
|
||||
$heart_data = $this->getRanking($room_id,$friend_id);
|
||||
//数组根据里面的heart_value 由大到小进行排序
|
||||
usort($heart_data, function($a, $b) {
|
||||
return $b['heart_value'] - $a['heart_value'];
|
||||
});
|
||||
$pit = [];
|
||||
$pit_number_array = [2=>5,1=>6,3=>4,5=>2,6=>1,4=>3]; //麦位对应关系
|
||||
$pit_number_array_reverse = [0=>2,1=>1,2=>3,3=>4,4=>5,5=>6];
|
||||
if($heart_data){
|
||||
//排麦位
|
||||
$pit_unique = [];
|
||||
$key = 0;
|
||||
foreach($heart_data as $value) {
|
||||
if(count($pit) >= 6){
|
||||
break;
|
||||
}
|
||||
|
||||
// 处理两个用户都存在的情况
|
||||
if($value['user1_id'] != -1 && $value['user2_id'] != -1){
|
||||
if(!in_array($value['user1_id'],$pit_unique)){
|
||||
// 检查目标麦位是否已被占用
|
||||
if(!isset($pit[$pit_number_array_reverse[$key]])) {
|
||||
$pit[$pit_number_array_reverse[$key]] = $value['user1_id'];
|
||||
$pit[$pit_number_array[$pit_number_array_reverse[$key]]] = $value['user2_id'];
|
||||
$pit_unique = array_merge($pit_unique, [$value['user1_id'], $value['user2_id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理只有user2存在的情况
|
||||
elseif($value['user1_id'] == -1 && !in_array($value['user2_id'],$pit_unique)){
|
||||
// 检查该键是否已被使用
|
||||
if(!isset($pit[$pit_number_array_reverse[$key]])) {
|
||||
$pit[$pit_number_array_reverse[$key]] = $value['user2_id'];
|
||||
$pit_unique[] = $value['user2_id'];
|
||||
}
|
||||
}
|
||||
// 处理只有user1存在的情况
|
||||
elseif($value['user2_id'] == -1 && !in_array($value['user1_id'],$pit_unique)){
|
||||
// 检查该键是否已被使用
|
||||
if(!isset($pit[$pit_number_array_reverse[$key]])) {
|
||||
$pit[$pit_number_array_reverse[$key]] = $value['user1_id'];
|
||||
$pit_unique[] = $value['user1_id'];
|
||||
}
|
||||
}
|
||||
$key++;
|
||||
}
|
||||
}
|
||||
return $pit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//换麦
|
||||
public function changePitToPosPairs($room_id,$friendPlayPit){
|
||||
$now_pit_u = array_flip($friendPlayPit);
|
||||
//按照键值排序数组
|
||||
ksort($now_pit_u);
|
||||
//查询现在麦位上有用户的数据 并且重组结果,键为麦位,值为用户,值必须存在,没值则不展示
|
||||
$pit_user = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7],'user_id' => ['>', 0]])
|
||||
->order('pit_number ASC')
|
||||
->column('pit_number,user_id');
|
||||
//比较两个数组,无论是键的差异还是值的差异,都输出字符串”有差异“否则输出”没有差异“
|
||||
$result = array_diff_assoc($pit_user, $now_pit_u);
|
||||
$result2 = array_diff_assoc($now_pit_u, $pit_user);
|
||||
if(!empty($result) || !empty($result2)){
|
||||
// var_dump('有差异');
|
||||
//获取实际麦位上的用
|
||||
$newPitUser = array_keys($friendPlayPit);
|
||||
//获取当前麦位上的用户
|
||||
$oldPitUser = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7]])->column('user_id');
|
||||
//获取交集
|
||||
$intersection = array_intersect($newPitUser,$oldPitUser);
|
||||
//取差集
|
||||
$diff = array_diff($newPitUser,$oldPitUser);
|
||||
$changeData = [];
|
||||
if($diff){
|
||||
//推下麦
|
||||
foreach($diff as $key => $value){
|
||||
if(in_array($value,$oldPitUser)){
|
||||
//查询当前空麦位
|
||||
$pit_null = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
if($pit_null){
|
||||
// $this->room_pit_model->getOnPit($this->room_id, $value, $pit_null);
|
||||
model('api/RoomPit')->OnPit($value, $room_id, $pit_null);
|
||||
// db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_null])->update(['user_id' => $value]);
|
||||
}else{
|
||||
//下麦
|
||||
$UserRoomPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value])->value('pit_number');
|
||||
model('api/RoomPit')->DownPit($value, $room_id, $UserRoomPit);
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array($value,$newPitUser)){
|
||||
//推上麦
|
||||
//获取目标麦位是否有人
|
||||
$getRoomPitUser= db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $friendPlayPit[$value]])->value('user_id');
|
||||
if($getRoomPitUser){
|
||||
//查询当前空麦位
|
||||
$getRoomNullPitss = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10,$friendPlayPit[$value]]);
|
||||
if($getRoomNullPitss){
|
||||
// $this->room_pit_model->getOnPit($this->room_id, $getRoomPitUser, $getRoomNullPitss);
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $getRoomNullPitss])->update(['user_id' => $getRoomPitUser]);
|
||||
}else{
|
||||
model('api/RoomPit')->DownPit($getRoomPitUser, $room_id, $friendPlayPit[$value]);
|
||||
}
|
||||
}
|
||||
model('api/RoomPit')->OnPit($value, $room_id, $friendPlayPit[$value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($intersection){//交换麦位
|
||||
//查询麦上的用户
|
||||
$newPitUserStr = implode(',',$newPitUser);
|
||||
$getRoomPit = db::name('vs_room_pit')->where("room_id=".$room_id." AND user_id in (".$newPitUserStr.")")->column('pit_number');
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['in', $getRoomPit]])->update(['user_id' => 0]);
|
||||
$changePitUser = [];
|
||||
foreach ($friendPlayPit as $key => $value){
|
||||
if(empty($value)){
|
||||
$value = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}
|
||||
//获取目标麦位是否有人
|
||||
$isPitHaveUser= db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $value])->value('user_id');
|
||||
if($isPitHaveUser && !in_array($isPitHaveUser,$newPitUser)){
|
||||
$changePitUser[$key]['user_id'] = $isPitHaveUser;
|
||||
$changePitUser[$key]['pit_number'] = $value;
|
||||
}
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $value])->update(['user_id' => $key]);
|
||||
}
|
||||
//处理原麦位上的用户
|
||||
foreach ($changePitUser as $key_change => $value_change){
|
||||
//判断是否在左边 1,,2,,3 麦位上
|
||||
if(in_array($value_change['pit_number'],[1,2,3])){
|
||||
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [4,5,6,7,8,9,10]);
|
||||
if(empty($null_pit)){
|
||||
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}
|
||||
}else{
|
||||
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [1,2,3,7,8,9,10]);
|
||||
if(empty($null_pit)){
|
||||
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}
|
||||
}
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $null_pit])->update(['user_id' => $value_change['user_id']]);
|
||||
}
|
||||
// $getRoomNullPit = $this->room_pit_model->where(['room_id'=>$room_id,'pit_number'=>['notin',[7,9]]])->select();
|
||||
$getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select();
|
||||
$data_users = [];
|
||||
foreach($getRoomNullPit as $key_data => $value_data){
|
||||
$data_users[$key_data]['user_id'] = $value_data['user_id'];
|
||||
$data_users[$key_data]['nickname'] = db::name('user')->where('id',$value_data['user_id'])->value('nickname');
|
||||
$data_users[$key_data]['avatar'] = db::name('user')->where('id',$value_data['user_id'])->value('avatar');
|
||||
$data_users[$key_data]['sex'] = db::name('user')->where('id',$value_data['user_id'])->value('sex');
|
||||
//获取用户在此房间今天的魅力值
|
||||
$charm =[];
|
||||
if($value_data['user_id']){
|
||||
$charm = db::name('vs_room_user_charm')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('charm');
|
||||
}
|
||||
$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'];
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = '房间换麦位';
|
||||
$text['list'] = $data_users;
|
||||
model('api/Chat')->sendMsg(1053,$room_id,$text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//换麦
|
||||
public function changePitToPosPair($room_id,$friendPlayPit){
|
||||
$new_pit_u = $friendPlayPit;
|
||||
//按照键值排序数组
|
||||
ksort($new_pit_u);
|
||||
//查询原有麦位上有用户的数据 并且重组结果,键为麦位,值为用户,值必须存在,没值则不展示
|
||||
$pit_users = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7],'user_id' => ['>', 0]])
|
||||
->order('pit_number ASC')
|
||||
->field('pit_number,user_id')->select();
|
||||
$pit_user = [];
|
||||
foreach ($pit_users as $value_pit_user){
|
||||
$pit_user[$value_pit_user['pit_number']] = $value_pit_user['user_id'];
|
||||
}
|
||||
//比较两个数组,无论是键的差异还是值的差异,都输出字符串”有差异“否则输出”没有差异“
|
||||
$result = array_diff_assoc($pit_user, $new_pit_u);//第一个数组中存在但其他数组中不存在的键/值对
|
||||
$result2 = array_diff_assoc($new_pit_u, $pit_user);
|
||||
if(!empty($result) || !empty($result2)){//换麦
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => ['<',7]])->update(['user_id' => 0]);
|
||||
//新麦位上的用户
|
||||
foreach ($new_pit_u as $key_result2 => $value_result2){
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $key_result2])->update(['user_id' => $value_result2]);
|
||||
}
|
||||
if($result){//原有麦位上的用户,且不在新麦位上的用户
|
||||
foreach ($result as $key_result => $value_result){
|
||||
$pit_null = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
$onPitUser = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value_result])->find();
|
||||
if($pit_null && !$onPitUser){
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_null])->update(['user_id' => $value_result]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select();
|
||||
$data_users = [];
|
||||
foreach($getRoomNullPit as $key_data => $value_data){
|
||||
$data_users[$key_data]['user_id'] = $value_data['user_id'];
|
||||
$data_users[$key_data]['nickname'] = db::name('user')->where('id',$value_data['user_id'])->value('nickname');
|
||||
$data_users[$key_data]['avatar'] = db::name('user')->where('id',$value_data['user_id'])->value('avatar');
|
||||
$data_users[$key_data]['sex'] = db::name('user')->where('id',$value_data['user_id'])->value('sex');
|
||||
//获取用户在此房间今天的魅力值
|
||||
$charm =[];
|
||||
if($value_data['user_id']){
|
||||
$charm = db::name('vs_room_user_charm')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('charm');
|
||||
}
|
||||
$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'];
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = '房间换麦位';
|
||||
$text['list'] = $data_users;
|
||||
model('api/Chat')->sendMsg(1053,$room_id,$text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//交友厅游戏开始后送礼后一系列操作
|
||||
//插入/更新心动表
|
||||
public function addUserHeart($uid,$user_id,$friend_id,$value,$room_id,$user_data){
|
||||
//给多个用户送礼
|
||||
//数组重组 下标从0开始
|
||||
$user_ids = array_values($user_id);
|
||||
// $heart_value = $value;//心动值
|
||||
$heart_value = 0;
|
||||
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
|
||||
for ($i = 0; $i < count($user_ids); $i++) {
|
||||
foreach ($user_data as $cv){
|
||||
if($user_ids[$i] == $cv['user_id']){
|
||||
$heart_value = $cv['gift_price'] * $heart_exp;
|
||||
}
|
||||
}
|
||||
// 处理用户ID顺序
|
||||
$user1 = min($uid, $user_ids[$i]);
|
||||
$user2 = max($uid, $user_ids[$i]);
|
||||
// 更新心动关系表
|
||||
$relation = db::name('vs_user_friending_heart')->where([
|
||||
'user1_id' => $user1,
|
||||
'user2_id' => $user2,
|
||||
'friend_id' => $friend_id
|
||||
])->find();
|
||||
|
||||
if ($relation) {
|
||||
db::name('vs_user_friending_heart')->where([
|
||||
'room_id' => $room_id,
|
||||
'user1_id' => $user1,
|
||||
'user2_id' => $user2,
|
||||
'friend_id' => $friend_id
|
||||
])->setInc('heart_value', $heart_value);
|
||||
} else {
|
||||
$relation['id'] = db::name('vs_user_friending_heart')->insert([
|
||||
'room_id' => $room_id,
|
||||
'user1_id' => $user1,
|
||||
'user2_id' => $user2,
|
||||
'friend_id' => $friend_id,
|
||||
'heart_value' => $heart_value
|
||||
]);
|
||||
}
|
||||
}
|
||||
//修改用户心动连线状态
|
||||
// $relation = db::name('vs_user_friending_heart')->where("(user1_id=".$uid." OR user2_id=".$uid.") AND friend_id=$friend_id AND room_id=$room_id AND status!=3")->order('heart_value desc')->find();
|
||||
// if($relation){
|
||||
// db::name('vs_user_friending_heart')->where("(user1_id=".$uid." OR user2_id=".$uid.") AND friend_id=$friend_id AND room_id=$room_id AND status!=3")->update(['status'=>2]);
|
||||
// db::name('vs_user_friending_heart')->where(['id'=>$relation['id']])->update(['status'=>1]);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class Gift extends Model
|
||||
//获取礼物类型
|
||||
public function get_gift_label()
|
||||
{
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->order("sort asc,id desc")->select();
|
||||
$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'];
|
||||
$giftType[$key]['name'] = $value['name'];
|
||||
@@ -28,41 +28,79 @@ class Gift extends Model
|
||||
}
|
||||
|
||||
//拉去礼物列表
|
||||
public function get_gift_list($label=0)
|
||||
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
|
||||
{
|
||||
$map['delete_time'] = 0;
|
||||
$where['is_show'] = 1;
|
||||
if ($label && $label !=99) {
|
||||
if ($label && $label != 99) {
|
||||
$map['label'] = $label;
|
||||
}
|
||||
if ($label == 99) {
|
||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
$where['label'] = ['<>',2];
|
||||
}
|
||||
$is_lock = 0;
|
||||
$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();
|
||||
|
||||
if($label==2){
|
||||
$list_data = [];
|
||||
foreach ($list as &$v) {
|
||||
//获取盲盒列表
|
||||
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where('activities_id',4)->select();
|
||||
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",[4,5]]])->select();
|
||||
foreach ($box_list as $key =>$box) {
|
||||
$ext = json_decode($box['ext'],true);
|
||||
if ($ext['gift_id'] == $v['gift_id']) {
|
||||
$v['gift_bag_name'] = $box['name'];
|
||||
$v['rule'] = $ext['description'];
|
||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"];
|
||||
$v['activities_id'] = $box['activities_id'];
|
||||
$v['gift_bag'] = $box['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($list as $gift) {
|
||||
if($is_open_blind_box_turntable == 1){
|
||||
$list_data[] = $gift;
|
||||
}else{
|
||||
if(isset($gift['activities_id']) && $gift['activities_id'] == 4){
|
||||
$list_data[] = $gift;
|
||||
}
|
||||
}
|
||||
}
|
||||
usort($list_data, function($a, $b) {
|
||||
return $a['gift_id'] <=> $b['gift_id'];
|
||||
});
|
||||
$list = $list_data;
|
||||
}
|
||||
if ($label == 11) { // 专属礼物
|
||||
$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;
|
||||
}
|
||||
}
|
||||
//获取配置里面的CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
$cp_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;
|
||||
}
|
||||
}
|
||||
//如果有CP礼物 则放在最前面
|
||||
if ($cp_gift) {
|
||||
array_unshift($list, ...$cp_gift);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
/*
|
||||
* 盲盒规则链接
|
||||
*/
|
||||
public function get_gift_box_rule($box_id){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,19 +17,22 @@ class Guild extends Model
|
||||
* @param $page
|
||||
* @param $limit
|
||||
*/
|
||||
public function get_guild_list($page,$limit=10,$search='',$user_id=0)
|
||||
public function get_guild_list($page,$page_limit,$search='',$user_id=0)
|
||||
{
|
||||
$where ="1=1";
|
||||
if ($search) {
|
||||
$where = ['guild_special_id'=>['like',$search.'%']]; //通过工会ID搜索
|
||||
$where =[];
|
||||
//判断是不是数字
|
||||
if (is_numeric($search)) {
|
||||
$where = ['guild_special_id'=>['like',$search.'%']]; //通过工会ID搜索
|
||||
}else{
|
||||
$where = ['guild_name'=>['like',$search.'%']];
|
||||
}
|
||||
$list = [];
|
||||
$list = Db::name('vs_guild')
|
||||
->field('id,guild_special_id,user_id,guild_name,cover,num,intro,createtime,income')
|
||||
->where(['is_show'=>1,'delete_time'=>0])
|
||||
->where($where)
|
||||
->order('income desc')
|
||||
->page($page,$limit)
|
||||
->page($page, $page_limit)
|
||||
->order('num desc')
|
||||
->select();
|
||||
$count = Db::name('vs_guild')
|
||||
->where(['is_show'=>1,'delete_time'=>0])
|
||||
@@ -62,7 +65,7 @@ class Guild extends Model
|
||||
}
|
||||
$data =[
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'list' => $list
|
||||
];
|
||||
@@ -112,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){
|
||||
@@ -126,7 +129,7 @@ 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();
|
||||
$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){
|
||||
return ['code'=>0,'msg'=>'您已加入别的工会,请先退出公会再加入', 'data' => null];
|
||||
}
|
||||
@@ -167,17 +170,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];
|
||||
@@ -208,7 +211,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)
|
||||
@@ -231,10 +234,12 @@ class Guild extends Model
|
||||
/*
|
||||
* 同意,拒绝申请
|
||||
*/
|
||||
public function operate_guild($uid, $apply_id, $type){
|
||||
$user_info = db::name('user')->find($uid);
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
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();
|
||||
@@ -245,7 +250,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];
|
||||
}
|
||||
//审核通过
|
||||
@@ -263,20 +268,37 @@ 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);
|
||||
}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];
|
||||
@@ -385,6 +407,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);
|
||||
@@ -401,6 +437,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);
|
||||
@@ -510,7 +547,7 @@ class Guild extends Model
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '解散失败', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '审核失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +562,7 @@ class Guild extends Model
|
||||
//成员解散
|
||||
db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'status'=>1,'delete_time'=>0])->update(['delete_time'=>time(),'quit_type'=>3,'quit_time'=>time()]);
|
||||
//解散公会
|
||||
db::name('vs_guild')->where('id',$guild_id)->update(['delete_time'=>time(),'is_show'=>2,'num'=>0,'guild_special_id'=>""]);
|
||||
db::name('vs_guild')->where('id',$guild_id)->update(['delete_time'=>time(),'status'=>2]);
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
Db::commit();
|
||||
@@ -610,8 +647,8 @@ class Guild extends Model
|
||||
//规则
|
||||
$data['rule'] = get_system_config_value('web_site').'/api/Page/page_show?id=15';
|
||||
//上周流水
|
||||
$week_start = date('Y-m-d', strtotime('last monday'));
|
||||
$week_end = date('Y-m-d', strtotime('last monday +6 days'));
|
||||
$week_start = date('Y-m-d 00:00:00', strtotime('last week Monday'));
|
||||
$week_end = date('Y-m-d 23:59:59', strtotime('last week Monday +6 days'));
|
||||
$guild_subsidy = db::name('vs_guild_subsidy')
|
||||
->where(["guild_id"=>$guild_id,'start_time' => $week_start, 'end_time' => $week_end])
|
||||
->find();
|
||||
@@ -622,18 +659,38 @@ class Guild extends Model
|
||||
$data['list'][0]['status_str'] = isset( $guild_subsidy['status'])&& $guild_subsidy['status']==1 ? "已发放" : "未发放";
|
||||
//本周流水
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d', strtotime('this week Monday')));
|
||||
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>null])->select();
|
||||
$guild_user_ids = array_column($guild_user,'room_id');
|
||||
$total_transaction = db::name('vs_give_gift')
|
||||
->where(['from'=>2,'from_id' => ['in',$guild_user_ids],'createtime' => ['between', [$week, time()]]])
|
||||
->sum('total_price');
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user as $k => $v){
|
||||
$week_start_time_seach = $week;
|
||||
$week_end_time_seach = time();
|
||||
if($v['createtime'] && $week_start_time_seach < $v['createtime']){
|
||||
$week_start_time_seach = $v['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
$week_end_time_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
|
||||
}
|
||||
$total_transaction = $transaction;
|
||||
$ss = 0;
|
||||
if($total_transaction){
|
||||
//根据工会流水 获取补贴比例 单位%
|
||||
$subsidy_config = db::name('vs_guild_subsidy_config')->where('start_amount <= '. $total_transaction)
|
||||
->where('end_amount > '. $total_transaction)->getField('subsidy_ratio');
|
||||
$ss = $total_transaction * ($subsidy_config / 100);
|
||||
//获取补贴配置
|
||||
$config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||
foreach ($config as $k => $v) {
|
||||
if ($total_transaction >= $v['end_amount']) {
|
||||
$subsidy_ratio = $v['subsidy_ratio'];
|
||||
$ss = ($total_transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||
break; // 找到匹配项后提前退出循环
|
||||
}
|
||||
}
|
||||
}
|
||||
//待开发
|
||||
$data['list'][1]['name'] = "本周流水";
|
||||
@@ -651,62 +708,68 @@ class Guild extends Model
|
||||
$coin_consumption_type_array = model('common/UserWallet')->coin_consumption_type_array;
|
||||
$coin_consumption_type_array = array_diff($coin_consumption_type_array, [model('common/UserWallet')::OPERATION_CONSUME]);
|
||||
|
||||
// // 获取所有工会成员的 user_id
|
||||
// $all_guild_users = Db::name('vs_guild_user')
|
||||
// ->where(['guild_id' => $guild_id, 'status' => 1, 'delete_time' => 0])
|
||||
// ->column('user_id');
|
||||
//
|
||||
// // 批量查询总消费
|
||||
// $total_consumption = Db::name('vs_user_money_log')
|
||||
// ->whereIn('change_type', $coin_consumption_type_array)
|
||||
// ->where(['money_type' => 1, 'createtime' => ['between', [$start_time, $end_time]]])
|
||||
// ->whereIn('user_id', $all_guild_users)
|
||||
// ->sum('change_value');
|
||||
//总消费
|
||||
//所有工会成员
|
||||
// 总消费 - 需要按时间限制并只统计加入工会后的消费
|
||||
if (!$start_time || !$end_time) {
|
||||
// 如果没有指定时间范围,则查询所有记录
|
||||
$start_time_filter = 0;
|
||||
$end_time_filter = time();
|
||||
} else {
|
||||
$start_time_filter = strtotime($start_time." 00:00:00");
|
||||
$end_time_filter = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
|
||||
// 所有工会成员
|
||||
$all_guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select();
|
||||
$total_consumption = 0;
|
||||
foreach ($all_guild_user as $key => $value) {
|
||||
if(!$start_time){
|
||||
$start_time_all = $value['createtime'];
|
||||
$end_time_all = time();
|
||||
}else{
|
||||
$start_time_all = strtotime($start_time." 00:00:00");
|
||||
$end_time_all = strtotime($end_time." 23:59:59");
|
||||
// 计算时间范围:取工会加入时间和指定时间范围的较大值作为开始时间
|
||||
$actual_start_time = max($value['createtime'], $start_time_filter);
|
||||
$actual_end_time = $end_time_filter;
|
||||
|
||||
// 如果开始时间大于结束时间,则跳过该用户
|
||||
if ($actual_start_time > $actual_end_time) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$consumption = db::name('vs_user_money_log')
|
||||
->whereIn('change_type',$coin_consumption_type_array)
|
||||
->where(['money_type'=>1,'user_id' => $value['user_id'],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->where(['money_type'=>1,'user_id' => $value['user_id']])
|
||||
->where('createtime', '>=', $actual_start_time)
|
||||
->where('createtime', '<=', $actual_end_time)
|
||||
->sum('change_value');
|
||||
$total_consumption = $total_consumption+$consumption;
|
||||
$total_consumption = $total_consumption + ($consumption ?: 0);
|
||||
}
|
||||
|
||||
if (!$start_time || !$end_time) {
|
||||
$start_time = strtotime('-1 month'); // 默认最近一个月
|
||||
// 如果没有指定时间范围,则查询所有记录
|
||||
$start_time = 0;
|
||||
$end_time = time();
|
||||
}else{
|
||||
$start_time = strtotime($start_time." 00:00:00");
|
||||
$end_time = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
|
||||
// 查询成员列表及各自消费
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime BETWEEN ' . $start_time . ' AND ' . $end_time, 'LEFT')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->group('a.user_id')
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime BETWEEN ' . $start_time . ' AND ' . $end_time, 'LEFT')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->group('a.user_id')
|
||||
->count();
|
||||
|
||||
$data = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$data[$k]['id'] = $v['id'];
|
||||
@@ -732,7 +795,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];
|
||||
@@ -741,6 +804,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();
|
||||
@@ -748,15 +813,21 @@ class Guild extends Model
|
||||
$start_time_all = strtotime($start_time." 00:00:00");
|
||||
$end_time_all = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_all = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_all = $value['quit_time'];
|
||||
}
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->where('from_id',$value['room_id'])
|
||||
->where(['from'=>2,'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->sum('total_price');
|
||||
$total_transaction = $total_transaction+$transaction;
|
||||
}
|
||||
//查询工会所有房间流水
|
||||
$list = db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'delete_time'=>0,'status'=>1,'room_id'=>['<>',0]])
|
||||
->order('coin desc')
|
||||
->order('id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
@@ -764,12 +835,20 @@ 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 = $v['createtime'];
|
||||
$end_time = time();
|
||||
$start_time_seach = $value['createtime'];
|
||||
$end_time_seach = time();
|
||||
}else{
|
||||
$start_time = strtotime($start_time." 00:00:00");
|
||||
$end_time = strtotime($end_time." 23:59:59");
|
||||
$start_time_seach = strtotime($start_time." 00:00:00");
|
||||
$end_time_seach = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_seach = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_seach = $value['quit_time'];
|
||||
}
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id'],'room_status'=>1,'delete_time'=>0])->find();
|
||||
if($room_info){
|
||||
@@ -779,7 +858,7 @@ class Guild extends Model
|
||||
$room_data[$i]['room_cover'] = localpath_to_netpath($room_info['room_cover']);
|
||||
$room_data[$i]['total_price'] = db::name('vs_give_gift')
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>2,'createtime' => ['between', [$start_time, $end_time]]])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_seach, $end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$i++;
|
||||
}
|
||||
@@ -803,100 +882,138 @@ 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){
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where(['a.guild_id'=>$guild_id,'a.status'=>1,'a.delete_time'=>0])
|
||||
->count();
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id, b.nickname, b.avatar, b.user_code, a.createtime')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$member_array = array_column($list, 'user_id');
|
||||
$member_array_str = [];
|
||||
foreach ($member_array as $k=> $v){
|
||||
$member_array_str[] = 'u' . $v;
|
||||
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')
|
||||
->where(['a.guild_id'=>$guild_id,'a.status'=>1,'a.delete_time'=>0])
|
||||
->count();
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id, b.nickname, b.avatar, b.user_code, a.createtime')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->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();
|
||||
}
|
||||
$group_member_info = model('Tencent')->get_group_member_info('g' .$guild_id,$member_array_str);
|
||||
if($group_member_info['code'] == 0){
|
||||
return V($group_member_info['code'],$group_member_info['msg'], $group_member_info['data']);
|
||||
}
|
||||
$member = [];
|
||||
foreach ($group_member_info['data'] as $k=> $v){
|
||||
$member[$v['Member_Account']] = $v['Role'];
|
||||
}
|
||||
//Owner(群主),Admin(群管理员),Member(普通群成员),NotMember(非群成员)。
|
||||
$role = [
|
||||
'Owner'=>'群主',
|
||||
'Admin'=>'群管理员',
|
||||
'Member'=>'普通群成员',
|
||||
'NotMember'=>'非群成员'
|
||||
];
|
||||
foreach ($list as $key => $value) {
|
||||
if($user_id == $value['user_id']){
|
||||
$list[$key]['is_self'] = 1;
|
||||
}else{
|
||||
$list[$key]['is_self'] = 0;
|
||||
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($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']);
|
||||
}
|
||||
$member = [];
|
||||
foreach ($group_member_info['data'] as $k=> $v){
|
||||
$member[$v['Member_Account']] = $v['Role'];
|
||||
}
|
||||
//Owner(群主),Admin(群管理员),Member(普通群成员),NotMember(非群成员)。
|
||||
$role = [
|
||||
'Owner'=>'群主',
|
||||
'Admin'=>'群管理员',
|
||||
'Member'=>'普通群成员',
|
||||
'NotMember'=>'非群成员'
|
||||
];
|
||||
foreach ($list as $key => $value) {
|
||||
if($user_id == $value['user_id']){
|
||||
$list[$key]['is_self'] = 1;
|
||||
}else{
|
||||
$list[$key]['is_self'] = 0;
|
||||
}
|
||||
$list[$key]['user_code'] = model('Decorate')->user_decorate_detail($value['user_id'], 6);
|
||||
//角色:
|
||||
$list[$key]['role'] = $member['u'.$value['user_id']];
|
||||
$list[$key]['role_str'] = $role[$list[$key]['role']];
|
||||
$list[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
//当前用户是否在房间
|
||||
$in_room = db::name('vs_room_visitor')->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id')
|
||||
->field('a.room_id')
|
||||
->where(['b.type_id' =>['<>',6]])
|
||||
->where(['a.user_id' => $value['user_id'], 'a.is_delete' => 1])
|
||||
->find();
|
||||
$list[$key]['in_room_id'] = $in_room['room_id'] ?? 0;
|
||||
}
|
||||
$list[$key]['user_code'] = model('Decorate')->user_decorate_detail($value['user_id'], 6);
|
||||
//角色:
|
||||
$list[$key]['role'] = $member['u'.$value['user_id']];
|
||||
$list[$key]['role_str'] = $role[$list[$key]['role']];
|
||||
$list[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
//当前用户是否在房间
|
||||
$in_room = db::name('vs_room_visitor')->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id')
|
||||
->field('a.room_id')
|
||||
->where(['b.type_id' =>['<>',6]])
|
||||
->where(['a.user_id' => $value['user_id'], 'a.is_delete' => 1])
|
||||
->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_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);
|
||||
//获取$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();
|
||||
$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'],
|
||||
@@ -909,7 +1026,180 @@ 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)
|
||||
{
|
||||
$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){
|
||||
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){
|
||||
return ['code'=>0,'msg'=>'您已提交申请,请耐心等待', '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();
|
||||
//收礼人最终的收益比例 = 未加入工会的收益 + 加入工会的收益
|
||||
$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);
|
||||
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']);
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ class Invited extends Model
|
||||
$invited_draw_conf = get_system_config_value('invited_draw');//分成比例
|
||||
$invited_draw = $invited_draw_conf / 100;
|
||||
$invited_draw_money = $money * $invited_draw;
|
||||
$invited_draw_money = $invited_draw_money / intval(get_system_config_value('rmb_coin_ratio')); //金币换算成钻石
|
||||
//修改用户资金
|
||||
$reslut = model('common/UserWallet')->change_user_money($invited_user_id, $invited_draw_money, model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::OPERATION_INVITE_REBATE, '邀请用户充值返利');
|
||||
if($reslut['code'] == 1){
|
||||
@@ -103,7 +104,7 @@ class Invited extends Model
|
||||
//查询用户昵称
|
||||
$v['nickname'] = model('User')->where('id', $v['sub_user_id'])->value('nickname');
|
||||
$v['coin'] = intval($v['coin']);
|
||||
$v['earnings'] = intval($v['earnings']);
|
||||
$v['earnings'] = number_format($v['earnings'], 2, '.', ''); // 保留两位小数
|
||||
$v['proportion'] = intval($v['proportion']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
|
||||
@@ -27,6 +27,7 @@ class Level extends Model
|
||||
{
|
||||
//规则
|
||||
$return['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=10";
|
||||
$return['coin_charm_exp'] = get_system_config_value('coin_charm_exp');
|
||||
//用户信息
|
||||
$user = model('User')->get_user_info($uid);
|
||||
//用户头像
|
||||
@@ -53,7 +54,8 @@ class Level extends Model
|
||||
//距离下个等级需要的经验
|
||||
$return['user']['next_level'] = $user['charm_level']+1;
|
||||
$return['user']['next_level_str'] = 'Lv.'.$return['user']['next_level'];
|
||||
$return['user']['next_exp'] = $user_level['next_level_exp'] - $user['wealth_exp'];
|
||||
$next_exp = $user_level['next_level_exp'] - $user['charm_exp'];
|
||||
$return['user']['next_exp'] = $next_exp <= 0 ? 0 : $next_exp;
|
||||
$return['user']['next_rights_icon'] = $user_level['next_rights_icon'];
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ class Level extends Model
|
||||
$return['level'][$key]['name'] = $value['name'];
|
||||
$return['level'][$key]['change_value'] = $value['change_value'];
|
||||
//当前用户距离当前段位的距离
|
||||
$return['level'][$key]['distance'] = $value['change_value'] - $user['wealth_exp'];
|
||||
$return['level'][$key]['distance'] = $value['change_value'] - $user['charm_exp'];
|
||||
$return['level'][$key]['rights_icon'] = $value['rights_icon'];
|
||||
}
|
||||
}
|
||||
@@ -107,6 +109,7 @@ class Level extends Model
|
||||
{
|
||||
//规则
|
||||
$return['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=11";
|
||||
$return['coin_wealth_exp'] = get_system_config_value('coin_wealth_exp');
|
||||
//用户信息
|
||||
$user = model('User')->get_user_info($uid);
|
||||
//用户头像
|
||||
@@ -142,7 +145,8 @@ class Level extends Model
|
||||
//距离下个等级需要的经验
|
||||
$return['user']['next_level'] = $user['wealth_level']+1;
|
||||
$return['user']['next_level_str'] = 'Lv.'.$return['user']['next_level'];
|
||||
$return['user']['next_exp'] = $user_level['next_level_exp'] - $user['wealth_exp'];
|
||||
$next_exp = $user_level['next_level_exp'] - $user['wealth_exp'];
|
||||
$return['user']['next_exp'] = $next_exp <= 0 ? 0 : $next_exp;
|
||||
$return['user']['next_coins'] = $user_level['next_coins'];
|
||||
}
|
||||
//获取等级
|
||||
@@ -226,11 +230,11 @@ class Level extends Model
|
||||
$return['next_level_icon'] = $next_level_data['image'];
|
||||
$return['next_coins'] = $next_level_data['coins'];
|
||||
}else{
|
||||
$return['next_level'] = 0;
|
||||
$return['next_level_name'] = '';
|
||||
$return['next_level_exp'] = 0;
|
||||
$return['next_level_icon'] = '';
|
||||
$return['next_coins'] = 0;
|
||||
$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_coins'] = $level_data['coins'];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
@@ -264,11 +268,11 @@ class Level extends Model
|
||||
$return['next_level_icon'] = $next_level_data['image'];
|
||||
$return['next_rights_icon'] = $next_level_data['rights_icon'];
|
||||
}else{
|
||||
$return['next_level'] = 0;
|
||||
$return['next_level_name'] = '';
|
||||
$return['next_level_exp'] = 0;
|
||||
$return['next_level_icon'] = '';
|
||||
$return['next_rights_icon'] = "";
|
||||
$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;
|
||||
}
|
||||
@@ -289,10 +293,11 @@ class Level extends Model
|
||||
$user_wealth_level = $user['wealth_level'];
|
||||
$user_wealth_exp = $user['wealth_exp'] + $wealth_exp;
|
||||
//判断是否达到下一级别
|
||||
$user_wealth = $this->get_wealth_level_to_level($user_wealth_level);
|
||||
if($user_wealth_exp>= $user_wealth['exp']){
|
||||
$user_wealth_level= $user_wealth['next_level'];
|
||||
}
|
||||
$user_wealth = $this->get_wealth_level_to_level_vlue($user_wealth_exp);
|
||||
// if($user_wealth_level>= $user_wealth['level']){
|
||||
// $user_wealth_level= $user_wealth['level'];
|
||||
// }
|
||||
$user_wealth_level= $user_wealth['level'];
|
||||
$update_data = [];
|
||||
$update_data['wealth_level'] = $user_wealth_level;
|
||||
$update_data['wealth_exp'] = $user_wealth_exp;
|
||||
@@ -319,10 +324,11 @@ class Level extends Model
|
||||
$user_charm_level = $user['charm_level'];
|
||||
$user_charm_exp = $user['charm_exp'] + $charm_exp;
|
||||
//判断是否达到下一级别
|
||||
$user_charm = $this->get_charm_level_to_level($user_charm_level);
|
||||
if($user_charm_exp>= $user_charm['exp']){
|
||||
$user_charm_level= $user_charm['next_level'];
|
||||
}
|
||||
$user_charm = $this->get_charm_level_to_level_vlue($user_charm_exp);
|
||||
// if($user_charm_level != $user_charm['level']){
|
||||
// $user_charm_level = $user_charm['level'];
|
||||
// }
|
||||
$user_charm_level = $user_charm['level'];
|
||||
$update_data = [];
|
||||
$update_data['charm_level'] = $user_charm_level;
|
||||
$update_data['charm_exp'] = $user_charm_exp;
|
||||
@@ -412,4 +418,141 @@ class Level extends Model
|
||||
}
|
||||
return ['code' => 1, 'msg' => "成功", 'data' => null];
|
||||
}
|
||||
|
||||
/*
|
||||
* 通过魅力值获取对应等级
|
||||
*/
|
||||
public function get_charm_level_to_level_vlue($charm_level){
|
||||
$return = [];
|
||||
$level_data = Db::name('vs_charm_level')->where(["change_value"=>['<',$charm_level]])->order('change_value','desc')->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'];
|
||||
}else{
|
||||
$return['level'] = 0;
|
||||
$return['level_name'] = '';
|
||||
$return['exp'] = 0;
|
||||
$return['level_icon'] = '';
|
||||
$return['rights_icon'] = "";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
/*
|
||||
* 通过财富值获取对应等级
|
||||
*/
|
||||
public function get_wealth_level_to_level_vlue($wealth_level){
|
||||
$return = [];
|
||||
$level_data = Db::name('vs_wealth_level')->where(["change_value"=>['<',$wealth_level]])->order('change_value','desc')->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'];
|
||||
}else{
|
||||
$return['level'] = 0;
|
||||
$return['level_name'] = '';
|
||||
$return['exp'] = 0;
|
||||
$return['level_icon'] = '';
|
||||
$return['rights_icon'] = "";
|
||||
}
|
||||
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($singer['status'] !=1){
|
||||
return ['code' => 0, 'msg' => "当前用户非歌手", 'data' => null];
|
||||
}
|
||||
$user_level = Db::name('vs_singer_level')->where(['level' => $singer['level']])->find();
|
||||
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['level']+1;
|
||||
$return['user']['next_level_str'] = 'Lv.'.$return['user']['next_level'];
|
||||
$next_exp = $user_level['change_value'] - $singer['exp'];
|
||||
$return['user']['next_exp'] = $next_exp <= 0 ? 0 : $next_exp;
|
||||
$return['user']['next_rights_icon'] = $user_level['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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,13 @@ 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];
|
||||
}
|
||||
@@ -30,7 +35,7 @@ class Login extends Model
|
||||
$data['username'] = $user_name;
|
||||
$data['mobile'] = $user_name;
|
||||
$data['nickname'] = '游客'.$user_code;
|
||||
$data['joinip'] = request()->ip();
|
||||
$data['joinip'] = $login_ip;
|
||||
$data['birthday'] = date('Y-m-d');
|
||||
$data['avatar'] = get_system_config_value('web_site').'/data/avatar/head_pic.png';
|
||||
$data['profile'] = '这个人很懒,什么都没写';
|
||||
@@ -96,6 +101,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);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $user_id,'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$return_res[0]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $return_res];
|
||||
}
|
||||
@@ -107,16 +117,44 @@ class Login extends Model
|
||||
$block = db::name('block')->where(['type_text' => $user_info['id'],'type' => 1])->find();
|
||||
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => '用户已被封禁', 'data' => null];
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
db('block')->where(['id' => $block['id']])->delete();
|
||||
$sms_error = db::name('sms_error')->where(['mobile' => $user_info['mobile']])->find();
|
||||
if($sms_error){
|
||||
db::name('sms_error')->where(['mobile' => $user_info['mobile']])->delete();
|
||||
}
|
||||
}else{
|
||||
if($block['block_time'] == 0){
|
||||
return ['code' => 301, 'msg' => '用户已被永久封禁', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 301, 'msg' => '用户已被封禁,解封时间:'.date('Y-m-d H:i:s',$block['block_time']), 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
$block = db::name('block')->where(['type_text' => $login_device,'type' => 2])->find();
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => '设备已被封禁', 'data' => null];
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
db('block')->where(['id' => $block['id']])->delete();
|
||||
}else{
|
||||
if($block['block_time'] == 0){
|
||||
return ['code' => 301, 'msg' => '设备已被永久封禁', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 301, 'msg' => '设备已被封禁,解封时间:'.date('Y-m-d H:i:s',$block['block_time']), 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
$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) {
|
||||
return ['code' => 0, 'msg' => 'ip已被封禁', 'data' => null];
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
db('block')->where(['id' => $block['id']])->delete();
|
||||
}else{
|
||||
if($block['block_time'] == 0){
|
||||
return ['code' => 301, 'msg' => 'ip已被永久封禁', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 301, 'msg' => 'ip已被封禁,解封时间:'.date('Y-m-d H:i:s',$block['block_time']), 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$save_data = [];
|
||||
@@ -135,7 +173,7 @@ class Login extends Model
|
||||
$return_res[$key]['tencent_im'] = '';
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '用户获取成功', 'data' => $return_res];
|
||||
return ['code' => 1, 'msg' => '用户获取成功!~', 'data' => $return_res];
|
||||
}else{
|
||||
$user_info = $phone_user['data'][0];
|
||||
}
|
||||
@@ -155,9 +193,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'] = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
$save_data['updatetime'] = time();
|
||||
$save_data['prevtime'] = $user_info['logintime'];//上次登录时间
|
||||
$save_data['is_online'] = 1;
|
||||
$reslut = model('User')->update($save_data);
|
||||
|
||||
if (!$reslut) {
|
||||
@@ -174,6 +213,13 @@ 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']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $user_info['id'],'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$return_res[0]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'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']){
|
||||
@@ -181,6 +227,16 @@ class Login extends Model
|
||||
}
|
||||
$return_res[0]['auth'] = $isAuth;
|
||||
|
||||
//是否可以发布动态
|
||||
$user_rechange = db::name('vs_user_recharge')->field('sum(money) as money')->where(['user_id' => $user_info['id'],'pay_status' => 2])->find();
|
||||
//系统配置
|
||||
$config_money = get_system_config_value('private_chat_recharge_money');
|
||||
if(($config_money > 0) && ($user_rechange['money'] < $config_money)){
|
||||
$return_res[0]['is_can_chat'] = 0;
|
||||
}else{
|
||||
$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];
|
||||
@@ -254,28 +310,52 @@ class Login extends Model
|
||||
return ['code' => 0, 'msg' => '密码不能为空', 'data' => null];
|
||||
}
|
||||
|
||||
$user_info = model('User')->where(['mobile' => $user_name,'status'=>1])->find();
|
||||
$user_info = model('User')->where(['mobile' => $user_name,'status'=>['<>',0]])->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 0, 'msg' => '用户不存在', 'data' => null];
|
||||
}
|
||||
//今天误次数
|
||||
$sms_count = db::name('sms_error')->where(['mobile' => $user_name,'createtime' => ['between', [strtotime(date('Y-m-d')), time()]]])->count();
|
||||
|
||||
if (md5($password) != $user_info['password']) {
|
||||
return ['code' => 0, 'msg' => '密码错误', 'data' => null];
|
||||
}
|
||||
$multi_user = [];
|
||||
//查询手机号绑定的账号
|
||||
$phone_user = $this->phone_login_query($user_name);
|
||||
if($phone_user['code'] == 1){
|
||||
//获取返回数据的长度
|
||||
if(count($phone_user['data']) >= 2){
|
||||
$multi_user = $phone_user['data'];
|
||||
if ($sms_count >= 5) {
|
||||
$user_id = db::name('user')->where('mobile', $user_name)->value('id');
|
||||
$block_num = db::name('block')->where(['type' => 1, 'type_text' => $user_id])->find();
|
||||
if(!$block_num){
|
||||
//封禁账号
|
||||
$error_data = [
|
||||
'type' => 1,
|
||||
'type_text' => $user_id,
|
||||
'block_time' => time() + 60 * 60 * 24,
|
||||
'block_note' => '账号登录异常被封禁24小时',
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('block')->insert($error_data);
|
||||
db::name('user')->where('id', $user_id)->update(['status' => 2]);
|
||||
}
|
||||
|
||||
return ['code' => 0, 'msg' => '登录错误次数过多,账号已被封禁,请联系管理员处理','data' =>null];
|
||||
}
|
||||
|
||||
$login = $this->login($user_info,$system,$login_device,$multi_user);
|
||||
$count_sms = max(5 - $sms_count, 0);
|
||||
if (md5($password) != $user_info['password']) {
|
||||
$data = [
|
||||
'mobile' => $user_name,
|
||||
'type' => 2,
|
||||
'sms' => $password,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('sms_error')->insert($data);
|
||||
return ['code' => 0, 'msg' => '密码错误,'.$count_sms.'次后账号将被封禁24小时', 'data' => null];
|
||||
}
|
||||
|
||||
$login = $this->login($user_info,$system,$login_device);
|
||||
if($login['code'] != 1){
|
||||
return $login;
|
||||
}
|
||||
|
||||
//登陆成功后 把所有的登录错误删除掉
|
||||
db::name('sms_error')->where(['mobile' => $user_name])->delete();
|
||||
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $login['data']];
|
||||
}
|
||||
|
||||
@@ -300,12 +380,24 @@ 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');
|
||||
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');
|
||||
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');
|
||||
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];
|
||||
}
|
||||
}
|
||||
else{
|
||||
return ['code' => 0, 'msg' => '登录类型错误', 'data' => null];
|
||||
@@ -327,6 +419,11 @@ 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']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $user_info_data['user_id'],'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$return_res[0]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $return_res];
|
||||
}
|
||||
|
||||
@@ -359,9 +456,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];
|
||||
@@ -371,10 +478,23 @@ class Login extends Model
|
||||
//注销
|
||||
public function cancel($token){
|
||||
$user_info = model('UserToken')->where('token', $token)->find();
|
||||
//用户注册时间
|
||||
$register_time = db::name('user')->where('id', $user_info['user_id'])->value('createtime');
|
||||
$config_time = get_system_config_value('reg_to_cancel');
|
||||
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]);
|
||||
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) {
|
||||
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()]);
|
||||
@@ -387,25 +507,16 @@ class Login extends Model
|
||||
db::name('vs_room')->where('id', $value['id'])->update(['room_status' => 3]);
|
||||
}
|
||||
}
|
||||
//查询用户所在房间
|
||||
$room_list = db::name('vs_room_visitor')->where('user_id', $user_info['user_id'])->select();
|
||||
if($room_list){
|
||||
foreach ($room_list as &$value) {
|
||||
model('Room')->quit_room($user_info['user_id'], $value['room_id'],$user_info['user_id']);
|
||||
}
|
||||
}
|
||||
|
||||
}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)->select();
|
||||
$mobile = db::name('user')->where(['mobile' => $mob,'status' => ['<>',0]])->select();
|
||||
if(isset($mobile) && count($mobile) < 2){
|
||||
$user_auth = db::name('user_auth')->where('mobile', $mobile[0]['mobile'])->find();
|
||||
if($user_auth){
|
||||
db::name('user_auth')->where('id', $user_auth['id'])->delete();
|
||||
}
|
||||
db::name('user_auth')->where('mobile', $mob)->delete();
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '注销成功', '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' => '成功'];
|
||||
}
|
||||
}
|
||||
364
application/api/model/Nobility.php
Normal file
364
application/api/model/Nobility.php
Normal file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
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,pay_coin,day')
|
||||
->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 ==0 || $is_renew ==2) {
|
||||
$pay_coin = $nobility_info['pay_coin'] ?? 0;
|
||||
}else{
|
||||
$pay_coin = $nobility_info['renew_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];
|
||||
}
|
||||
}
|
||||
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'] - $surplus_time_hour * (($nobility_info['pay_price'] / $nobility_info['day']) / 24); //一小时的价格算
|
||||
}
|
||||
}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();
|
||||
$return = [
|
||||
'lid' => $nobility_info['lid'],
|
||||
'nobility_name' => $nobility_info['name'],
|
||||
'nobility_image' => $nobility_info['image'],
|
||||
'price' => round($price, 2),
|
||||
'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;
|
||||
}
|
||||
}
|
||||
@@ -40,26 +40,7 @@ class Ranking extends Model
|
||||
//财富、魅力榜
|
||||
public function ranking($ranking_type)
|
||||
{
|
||||
if($ranking_type == 1){//1财富榜,2魅力榜
|
||||
$field = 'a.user_id,b.user_code,b.nickname,b.avatar,sum(a.total_wealth) as total';
|
||||
$order = 'total desc';
|
||||
$where['a.total_wealth'] = ['>', 0];
|
||||
}else{
|
||||
$field = 'a.user_id,b.user_code,b.nickname,b.avatar,sum(a.total_charm) as total';
|
||||
$order = 'total desc';
|
||||
$where['a.total_charm'] = ['>', 0];
|
||||
}
|
||||
$where['a.updatetime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
|
||||
$lists = db::name('vs_room_user_charm')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field($field)
|
||||
->where($where)
|
||||
->order($order)
|
||||
->group('a.user_id')
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
@@ -67,45 +48,109 @@ class Ranking extends Model
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($lists){
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
if($ranking_type == 1){//1财富榜,2魅力榜
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.user_id')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
if($lists){
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->where('a.user_id',$this->user_id)
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.gift_user')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
if($lists){
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->where('a.gift_user',$this->user_id)
|
||||
->select();
|
||||
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_room_user_charm')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($where)
|
||||
->where('a.user_id',$this->user_id)
|
||||
->field($field)
|
||||
->find();
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
}
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -117,15 +162,17 @@ class Ranking extends Model
|
||||
//房间榜
|
||||
public function room_ranking()
|
||||
{
|
||||
//金币与魅力比例
|
||||
$ratio = get_system_config_value('coin_charm_exp');
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where['b.type_id'] = ['<>', 6];
|
||||
$where['b.room_status'] = 1;
|
||||
$field = ['sum(a.total_price) as total,b.room_name,a.from_id as room_id,b.room_cover,b.room_number'];
|
||||
$field = ['sum(a.total_price) *'.$ratio.' as total,b.room_name,a.from_id as room_id,b.room_cover,b.room_number'];
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_room b','a.from_id = b.id','left')
|
||||
->where($where)->field($field)->group('a.from_id')
|
||||
->order('total desc')
|
||||
->page($this->page, $this->page_limit)
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
@@ -196,6 +243,8 @@ class Ranking extends Model
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -234,7 +283,12 @@ class Ranking extends Model
|
||||
}
|
||||
|
||||
$lists = $guilds ;
|
||||
$my_ranking = null;
|
||||
// $my_ranking = null;
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($lists){
|
||||
//获取当前用户的工会
|
||||
$myGuild = db::name('vs_guild_user')->where(['user_id' => UID])->find();
|
||||
@@ -305,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')
|
||||
@@ -370,6 +425,32 @@ 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,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ class RoomAuction extends Model
|
||||
//房间关系列表
|
||||
public function room_relation_list($type_id)
|
||||
{
|
||||
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where('type',$type_id)->select();
|
||||
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where(['type' => $type_id,'delete_time' => 0])->select();
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => $list];
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -109,7 +109,7 @@ class RoomAuction extends Model
|
||||
|
||||
|
||||
//参与竞拍
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type)
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$ext=[])
|
||||
{
|
||||
if(!$auction_id){
|
||||
return ['code' => 0, 'msg' => '拍卖已经结束','data' => null];
|
||||
@@ -127,7 +127,7 @@ class RoomAuction extends Model
|
||||
}
|
||||
|
||||
//走送礼流程
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0);
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0,$ext);
|
||||
if($ree['code'] != 1){
|
||||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class RoomAuction extends Model
|
||||
'auction_id' => $auction_id,
|
||||
'user_id' => $user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_price' => $num * $gift_price,
|
||||
'gift_price' => $ree['data']['gift_total'],
|
||||
'createtime' => time()
|
||||
]);
|
||||
if(!$res){
|
||||
@@ -167,7 +167,7 @@ class RoomAuction extends Model
|
||||
->where(['auction_id' => $auction_id])
|
||||
->group('user_id')
|
||||
->having('gift_prices >= ' . $auction['gift_price'])
|
||||
->order('gift_prices DESC')
|
||||
->order('gift_prices DESC, id ASC')
|
||||
->limit(6)
|
||||
->select();
|
||||
if($list){
|
||||
@@ -292,9 +292,11 @@ class RoomAuction extends Model
|
||||
//查询是否有电影房
|
||||
$cp_movie = $this->movie_room_create_or_add($list['user_id'],$res['user_id'],$res['relation_id'],$res['time_day']);
|
||||
if($cp_movie['code'] != 1){
|
||||
return ['code' => 0, 'msg'=>$cp_movie['msg'], 'data'=>$cp_movie['data']];
|
||||
// return ['code' => 0, 'msg'=>$cp_movie['msg'], 'data'=>$cp_movie['data']];
|
||||
}else{
|
||||
$cp_room_id = $cp_movie['data']['cp_room_id'];
|
||||
}
|
||||
$cp_room_id = $cp_movie['data']['cp_room_id'];
|
||||
|
||||
}
|
||||
$texts = '恭喜'.$auction['nickname'].' 和 '.$recipient['nickname'].',获得'.$auction['relation_name'].' 关系'.$auction['time_day'].'小时';
|
||||
}else{//拍得无关系
|
||||
@@ -438,10 +440,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;
|
||||
}
|
||||
}
|
||||
73
application/api/model/RoomHourRanking.php
Normal file
73
application/api/model/RoomHourRanking.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class RoomHourRanking extends Model
|
||||
{
|
||||
//房间小时榜
|
||||
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');
|
||||
|
||||
// 更进一步的优化版本:
|
||||
$subQuery = Db::name('vs_give_gift')
|
||||
->where('from', 2)
|
||||
->whereBetween('createtime', [$start_time, $end_time])
|
||||
->buildSql();
|
||||
|
||||
$profit = db::name('vs_room')->alias('a')
|
||||
->join([$subQuery => 'b'], 'a.id = b.from_id', 'left')
|
||||
->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
->field('a.id as room_id,a.user_id,a.room_name,a.label_id,a.room_cover,IFNULL(SUM(b.total_price), 0) as total_price,c.label_icon')
|
||||
->where('a.room_status', 1)
|
||||
->where('a.apply_status', 2)
|
||||
->where('a.type_id', '<>', 6)
|
||||
->group('a.id')
|
||||
->order('total_price', 'desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
if($profit){
|
||||
foreach ($profit as &$v) {
|
||||
$v['total_price'] = $v['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
if($v['room_id'] > 0 && $is_open_xlh == 1){
|
||||
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
|
||||
$v['xlh_status'] = $xlh_status['xlh_status'];
|
||||
}else{
|
||||
$v['xlh_status'] = 0;
|
||||
}
|
||||
//查询房间是否有红包
|
||||
if($v['room_id'] > 0){
|
||||
$red_pack_status = Db::name('redpacket')->where(['room_id' => $v['room_id'], 'status' => ['<=',1]])->count();
|
||||
$v['redpacket_status'] = $red_pack_status;
|
||||
}else{
|
||||
$v['redpacket_status'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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];
|
||||
}
|
||||
|
||||
//此房间类型为特殊存在,修改房间类型的时候 要判断一下条件
|
||||
$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,6 @@ 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();
|
||||
//推送消息
|
||||
$text = [
|
||||
'text' => '房间类型变成k歌--2'
|
||||
@@ -159,8 +162,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];
|
||||
}
|
||||
|
||||
@@ -285,9 +288,14 @@ class RoomSong extends Model
|
||||
|
||||
|
||||
//上移歌 $type 1上移 2置顶
|
||||
public function up_song($room_song_id,$type=1){
|
||||
public function up_song($user_id,$room_song_id,$type=1){
|
||||
//查询当前数据的信息
|
||||
$sort = db::name('vs_room_song')->where('did',$room_song_id)->field('room_id,sort,times')->find();
|
||||
//查询当前用户是否是在9号麦的主持
|
||||
$is_host = db::name('vs_room_pit')->where(['user_id' => $user_id,'room_id' => $sort['room_id'],'pit_number' =>9])->find();
|
||||
if(!$is_host){
|
||||
return ['code'=>0,'msg'=>'您没有权限操作','data'=>null];
|
||||
}
|
||||
//根据房间ID查询当前房间中正在排序的歌曲 并获取当前排序的前一位的ID
|
||||
$sort_up = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])->field('did')->order('sort desc')->select();
|
||||
if($sort_up[0]['did'] == $room_song_id){
|
||||
@@ -529,7 +537,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);
|
||||
|
||||
690
application/api/model/Sign.php
Normal file
690
application/api/model/Sign.php
Normal file
@@ -0,0 +1,690 @@
|
||||
<?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_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')->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 = db::name('user')->where('id',$sign_user['user_id'])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('api/UserData')->user_wealth_icon($sign_user['user_id']);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('api/UserData')->user_charm_icon($sign_user['user_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $sign_user['user_id'],'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$FromUserInfo['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
|
||||
//组个列表
|
||||
$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])->order('sign_value desc')->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();
|
||||
//修改他的状态
|
||||
$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];
|
||||
}
|
||||
}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[$i] = db::name('vs_user_sign_task')->insert($data1);
|
||||
if(!$result[$i]){
|
||||
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];
|
||||
}
|
||||
db::commit();
|
||||
//给前端推送
|
||||
$FromUserInfo = db::name('user')->where('id',$max_sign_user['user_id'])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('api/UserData')->user_wealth_icon($max_sign_user['user_id']);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('api/UserData')->user_charm_icon($max_sign_user['user_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $max_sign_user['user_id'],'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$FromUserInfo['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
$ToUserInfo = db::name('user')->where('id',$max_sign_user['sign_user_id'])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$ToUserInfo['icon'][0] = model('api/UserData')->user_wealth_icon($max_sign_user['sign_user_id']);//财富图标
|
||||
$ToUserInfo['icon'][1] = model('api/UserData')->user_charm_icon($max_sign_user['sign_user_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinnger = db::name('vs_singer')->where(['user_id' => $max_sign_user['sign_user_id'],'status' => 1])->value('level');
|
||||
if($isSinnger){
|
||||
$ToUserInfo['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinnger,'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
|
||||
$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,is_online')->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'];
|
||||
|
||||
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]);
|
||||
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]);
|
||||
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];
|
||||
}
|
||||
|
||||
}
|
||||
445
application/api/model/SingerSong.php
Normal file
445
application/api/model/SingerSong.php
Normal file
@@ -0,0 +1,445 @@
|
||||
<?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];
|
||||
}
|
||||
//获取当前房间内点歌总数
|
||||
$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])->order('id desc')->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']]);
|
||||
}
|
||||
}
|
||||
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];
|
||||
}
|
||||
}
|
||||
@@ -20,23 +20,55 @@ class Sms extends Model
|
||||
if (!checkMobile($mobile)) {
|
||||
return ['code' => 0, 'msg' => '手机号不正确','data' =>null];
|
||||
}
|
||||
|
||||
//今天验证码错误次数
|
||||
$sms_count = db::name('sms_error')->where(['mobile' => $mobile,'createtime' => ['between', [strtotime(date('Y-m-d')), time()]]])->count();
|
||||
if ($sms_count >= 5) {
|
||||
$user_id = db::name('user')->where('mobile', $mobile)->value('id');
|
||||
$block_num = db::name('block')->where(['type' => 1, 'type_text' => $user_id])->find();
|
||||
if(!$block_num){
|
||||
//封禁账号
|
||||
$error_data = [
|
||||
'type' => 1,
|
||||
'type_text' => $user_id,
|
||||
'block_time' => time() + 60 * 60 * 24,
|
||||
'block_note' => '账号登录异常被封禁24小时',
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('block')->insert($error_data);
|
||||
db::name('user')->where('id', $user_id)->update(['status' => 2]);
|
||||
}
|
||||
|
||||
return ['code' => 0, 'msg' => '验证码错误次数过多,账号已被封禁,请联系管理员处理','data' =>null];
|
||||
}
|
||||
|
||||
$is_code = db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->order('id desc')->find();
|
||||
if ($is_code && $is_code['code'] == $code) {
|
||||
//验证码正确
|
||||
if($type == 1 || $type == 2){
|
||||
//查询手机号绑定的数量
|
||||
$map = [];
|
||||
$map[] = ['mobile', '=', $mobile];
|
||||
$map[] = ['status', '=', 1];
|
||||
$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_error')->where(['mobile' => $mobile])->delete();
|
||||
return ['code' =>1, 'msg' =>'验证码正确','data' =>null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '验证码错误','data' =>null];
|
||||
//验证码错误次数
|
||||
$count_sms = max(5 - $sms_count, 0);
|
||||
$data = [
|
||||
'mobile' => $mobile,
|
||||
'sms' => $code,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('sms_error')->insert($data);
|
||||
return ['code' => 0, 'msg' => '验证码错误,'.$count_sms.'次后账号将被封禁24小时','data' =>null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use fast\Http;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\facade\Env;
|
||||
use fast\Tencentst;
|
||||
|
||||
class Tencent extends Model
|
||||
@@ -154,7 +153,7 @@ class Tencent extends Model
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
// Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}else{
|
||||
@@ -206,7 +205,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' => $reslut];
|
||||
}else{
|
||||
@@ -242,9 +241,9 @@ class Tencent extends Model
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("广播消息信息".json_encode($reslut),"info");
|
||||
Log::record("广播消息信息3".json_encode($admin_sig),"info");
|
||||
Log::record("广播消息信息2".$admin_sig,"info");
|
||||
// Log::record("广播消息信息".json_encode($reslut),"info");
|
||||
// Log::record("广播消息信息3".json_encode($admin_sig),"info");
|
||||
// Log::record("广播消息信息2".$admin_sig,"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => $reslut];
|
||||
}else{
|
||||
@@ -283,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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -365,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{
|
||||
@@ -420,11 +423,11 @@ class Tencent extends Model
|
||||
if($OnlineOnlyFlag == 1){
|
||||
$curlPost['OnlineOnlyFlag'] = 1;
|
||||
}
|
||||
Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
// Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("xitong消息信息2:".$reslut,"info");
|
||||
// Log::record("xitong消息信息2:".$reslut,"info");
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
@@ -726,6 +729,35 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//修改用户信息
|
||||
public function modify_user_infos($member_id, $member_name = '', $member_face_url = '')
|
||||
{
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/profile/portrait_set?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['From_Account'] = 'u'.$member_id;
|
||||
$curlPost['ProfileItem'] = [
|
||||
[
|
||||
'Tag' => 'Tag_Profile_IM_Nick',
|
||||
'Value' => $member_name
|
||||
],
|
||||
[
|
||||
'Tag' => 'Tag_Profile_IM_Image',
|
||||
'Value' => $member_face_url
|
||||
]
|
||||
];
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//====新写的↓=====上面的 能用则用=============================================================================================================
|
||||
|
||||
@@ -810,7 +842,13 @@ class Tencent extends Model
|
||||
|
||||
// 处理响应
|
||||
if ($httpCode == 200) {
|
||||
return json_decode($response, true)['result']['faceId'];
|
||||
$red = json_decode($response, true);
|
||||
if ($red['code'] == 0) {
|
||||
return $red['result']['faceId'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => $red['msg'], 'data' => null];
|
||||
}
|
||||
// return json_decode($response, true)['result']['faceId'];
|
||||
} else {
|
||||
return ['code' => $httpCode, 'msg' => '接口请求失败'];
|
||||
}
|
||||
@@ -858,5 +896,188 @@ class Tencent extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//腾讯IM回调
|
||||
public function tencent_call_back($data,$sign_data){
|
||||
//回调鉴权
|
||||
// $token = '2k1j90av9rtl2ozbnbqxzyrtuj4a4oy5';
|
||||
// $sign = sha256($token.$sign_data['RequestTime']);
|
||||
// // $datas = json_encode($data);
|
||||
// // error_log($datas, 3, '1.txt');
|
||||
// // $sign_datas = json_encode($sign_data);
|
||||
// if($sign != $sign_data['Sign']){
|
||||
// return ['ActionStatus' => 'FAIL', 'ErrorInfo' => '', 'ErrorCode' => 1];
|
||||
// }
|
||||
// dump($data);exit;
|
||||
|
||||
|
||||
//在线状态更新
|
||||
if($data['CallbackCommand'] == 'State.StateChange'){
|
||||
$info = $data['Info'];
|
||||
$reslut = $this->tencent_member_status_change($info);
|
||||
}
|
||||
return ['ActionStatus' => 'OK', 'ErrorInfo' => '', 'ErrorCode' => 0];
|
||||
}
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_changeee($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
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 = 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;
|
||||
}
|
||||
|
||||
//腾讯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 {
|
||||
// //查询是否有切后台的操作
|
||||
// // $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 = 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user