250 Commits

Author SHA1 Message Date
077a0e23e0 关系 2026-01-31 15:39:17 +08:00
b65b416e89 赠送爵位 2026-01-31 10:03:48 +08:00
3d6d14d6a9 礼物墙 2026-01-30 19:36:04 +08:00
e2fb2c4f05 bug修改 2026-01-30 19:19:04 +08:00
3f30ee6062 bug修改 2026-01-30 19:16:08 +08:00
0985204f1d bug修改 2026-01-30 19:14:15 +08:00
ee533bbe73 bug修改 2026-01-30 19:12:41 +08:00
14f9ac26d4 bug修改 2026-01-30 19:06:42 +08:00
41c6a1d51e 礼物墙 2026-01-30 19:02:54 +08:00
bdf072663a bug修改 2026-01-30 19:00:16 +08:00
9600bd5103 bug修改 2026-01-30 18:55:38 +08:00
5afeecdfc1 礼物墙 2026-01-30 18:45:06 +08:00
89d994554e 礼物墙 2026-01-30 18:43:36 +08:00
d3687c0565 排麦列表 2026-01-30 17:53:41 +08:00
5de94eb016 排麦列表 2026-01-30 17:50:27 +08:00
40a70c20e2 bug修改 2026-01-30 17:17:25 +08:00
30b580f374 bug修改 2026-01-30 16:56:17 +08:00
961e4c7788 趣味礼物排序 2026-01-30 16:05:13 +08:00
4fd29220e9 bug修改 2026-01-30 14:11:37 +08:00
41c849999a bug修改 2026-01-30 11:09:30 +08:00
485d460c7b 趣味礼物排序 2026-01-30 10:23:41 +08:00
45fe36a98b 趣味礼物排序 2026-01-30 10:22:55 +08:00
47f0e0143c 趣味礼物排序 2026-01-30 10:16:25 +08:00
906517d103 Merge remote-tracking branch 'origin/develop' into develop 2026-01-30 10:12:41 +08:00
8683aed1d9 bug修改 2026-01-30 10:12:24 +08:00
38fb18899b 趣味礼物排序 2026-01-30 10:08:46 +08:00
9c1f2793c2 私密设置整理 2026-01-30 09:16:55 +08:00
6a58f37a76 私密设置整理 2026-01-30 09:15:36 +08:00
b18517abf2 房间修改为签约 取消热门 2026-01-30 09:14:39 +08:00
0f80219b71 开盲盒补偿数据 2026-01-30 09:12:27 +08:00
fed756efae 私密设置整理 2026-01-29 18:18:57 +08:00
54848b2864 私密设置整理 2026-01-29 18:02:27 +08:00
c839743f50 热门房间 2026-01-29 17:55:31 +08:00
18c88570f0 bug修改 2026-01-29 17:27:36 +08:00
14660c72be bug修改 2026-01-29 17:15:25 +08:00
84dac71bd6 封禁 强制退出 2026-01-29 17:06:35 +08:00
f4a5b2ced8 开关调整 2026-01-29 16:36:48 +08:00
c7eece32d6 开关调整 2026-01-29 16:34:45 +08:00
d8f244caf0 Merge remote-tracking branch 'origin/develop' into develop 2026-01-29 16:30:45 +08:00
8089ce8c6a 爵位赠送不送金币 2026-01-29 16:30:39 +08:00
612bb07bec 封禁 强制退出 2026-01-29 16:24:58 +08:00
8107d9961e 爱豆计划调整 2026-01-29 16:23:13 +08:00
de2ec9ff87 爱豆计划调整 2026-01-29 16:19:24 +08:00
742722544c 失效退出登录 2026-01-29 16:06:03 +08:00
cbecd88a3a 爱豆计划调整 2026-01-29 15:06:52 +08:00
f4fcfef729 爱豆计划调整 2026-01-29 14:28:54 +08:00
cee9802959 爱豆计划调整 2026-01-29 10:25:36 +08:00
254aee03e8 爱豆计划调整 2026-01-29 10:18:29 +08:00
1b0043743b 抽奖记录 2026-01-29 09:28:36 +08:00
46c07ac9e1 恋仙传奇 搬移。 2026-01-29 09:10:10 +08:00
3d491faed5 恋仙传奇 搬移。 2026-01-28 18:57:43 +08:00
51cb1ac2f4 幸运币列表倍数 2026-01-28 15:38:42 +08:00
4bcd069c85 收到礼物数 2026-01-28 14:13:39 +08:00
66edc41718 爆币 2026-01-28 11:53:13 +08:00
bf1b69b1cb Merge remote-tracking branch 'origin/develop' into develop 2026-01-28 11:34:09 +08:00
c2674ea33e 恋仙传奇 搬移。 2026-01-28 11:34:03 +08:00
15c8098b1f 爆币 2026-01-28 11:32:55 +08:00
9ca9909e6f 恋仙传奇 搬移。 2026-01-28 11:19:57 +08:00
fcca1cd794 恋仙传奇 搬移。 2026-01-28 10:55:22 +08:00
4a5fc09ce4 爆币 2026-01-28 10:46:25 +08:00
1160d9f908 恋仙传奇 搬移。 2026-01-28 10:42:19 +08:00
5f6c99538f 恋仙传奇 搬移。 2026-01-28 10:36:14 +08:00
8e4086b4ca 恋仙传奇 搬移。 2026-01-28 10:00:01 +08:00
765fafe218 连线传奇 搬移。 2026-01-28 09:53:35 +08:00
14ea649634 连线传奇 搬移。 2026-01-28 09:50:41 +08:00
de6676895a 爆币 2026-01-28 09:42:04 +08:00
2eeee057f8 连线传奇 搬移。 2026-01-28 09:11:41 +08:00
466db48ac2 连线传奇 搬移。 2026-01-27 20:44:37 +08:00
e8894d95cf 爆币 2026-01-27 20:35:25 +08:00
aff3440e42 连线传奇 搬移。 2026-01-27 20:32:29 +08:00
fc368aeda4 爆币 2026-01-27 20:32:04 +08:00
841f19e551 爆币 2026-01-27 20:30:36 +08:00
8b12d46912 爆币 2026-01-27 20:26:35 +08:00
a8725713aa Merge remote-tracking branch 'origin/develop' into develop 2026-01-27 20:16:47 +08:00
a6420812df 连线传奇 搬移。 2026-01-27 20:16:42 +08:00
c26e96f3dd 爆币 2026-01-27 20:15:41 +08:00
8b3d340456 Merge remote-tracking branch 'origin/develop' into develop 2026-01-27 20:13:11 +08:00
9fbf23279b 连线传奇 搬移。 2026-01-27 20:13:04 +08:00
786295bc47 爆币 2026-01-27 20:12:31 +08:00
31181d74c7 连线传奇 搬移。 2026-01-27 20:01:19 +08:00
7f82bb539e 爆币 2026-01-27 19:37:24 +08:00
935ef9f998 爆币 2026-01-27 19:25:16 +08:00
5f5954da52 管理后台-封禁-调试 2026-01-27 11:47:46 +08:00
d9eb6d01bf 管理后台-封禁-调试 2026-01-27 10:42:00 +08:00
4a2fdadfdb 管理后台-封禁-调试 2026-01-27 10:35:01 +08:00
7b990a5ecd 管理后台-封禁-调试 2026-01-27 10:30:02 +08:00
ac2c12c0c9 管理后台-封禁-调试 2026-01-27 10:27:22 +08:00
f4da4ffae9 管理后台-封禁-调试 2026-01-27 10:13:42 +08:00
210a325688 管理后台-封禁-调试 2026-01-27 10:09:17 +08:00
3567e02642 管理后台-封禁-调试 2026-01-27 10:05:18 +08:00
c7a70cb128 发送系统消息修改 2026-01-27 09:58:48 +08:00
466d94fda4 管理后台-封禁-调试 2026-01-27 09:51:32 +08:00
aedf9e1559 管理后台-封禁-调试 2026-01-27 09:35:31 +08:00
fcff5c1da5 管理后台-封禁-调试 2026-01-27 09:32:22 +08:00
808a111853 管理后台-封禁-调试 2026-01-27 09:30:27 +08:00
a38317a58c 管理后台-封禁-调试 2026-01-27 09:14:22 +08:00
486f42bd5b 管理后台-封禁 2026-01-27 09:00:12 +08:00
02ce80b8ed 爆币 2026-01-26 20:46:24 +08:00
1598df9824 爆币 2026-01-26 20:32:25 +08:00
2fc52ee53a 爆币 2026-01-26 20:00:19 +08:00
67703d073f 爆币 2026-01-26 19:59:00 +08:00
ff65b56590 爆币 2026-01-26 19:49:13 +08:00
f733aefd03 爆币 2026-01-26 19:41:53 +08:00
9dcec5fb27 爆币 2026-01-26 19:38:04 +08:00
bda215d894 Merge remote-tracking branch 'origin/develop' into develop 2026-01-26 19:37:07 +08:00
f1570369bd 管理后台-封禁 2026-01-26 19:37:02 +08:00
cf6ac7c0b1 爆币 2026-01-26 19:36:22 +08:00
853fb0b89e 管理后台-封禁 2026-01-26 19:32:53 +08:00
fc60a58a9c 管理后台-封禁 2026-01-26 19:29:09 +08:00
cbf3eaf788 爆币 2026-01-26 19:26:36 +08:00
7eeffdce65 爆币 2026-01-26 19:24:12 +08:00
07bf0d24f6 爆币 2026-01-26 19:21:32 +08:00
b8b87401ce 爆币 2026-01-26 19:05:43 +08:00
a7964a0b43 爆币 2026-01-26 18:19:12 +08:00
b4710619ff 爆币 2026-01-26 18:03:55 +08:00
42e660d618 爆币 2026-01-26 18:00:16 +08:00
8b28b1c96e 爆币 2026-01-26 17:38:07 +08:00
1212473b9e 爆币 2026-01-26 17:24:49 +08:00
01cc7a87ed 管理后台-礼盒管理-礼盒领取记录 2026-01-26 17:17:21 +08:00
f929f33867 JS支付 2026-01-26 16:51:55 +08:00
232a447217 修改房间类型 及房间类型列表 2026-01-26 16:27:07 +08:00
eaddbdcd06 房间热度卡开发-礼物列表调整 2026-01-26 15:02:58 +08:00
960eb2bb11 Merge remote-tracking branch 'origin/develop' into develop 2026-01-26 15:01:41 +08:00
764cb6947b 房间热度卡开发-礼物列表调整 2026-01-26 15:01:36 +08:00
605cdb3197 爆币(幸运币)修改 2026-01-26 14:46:00 +08:00
8dda53e52e 房间热度卡开发-礼物列表调整 2026-01-26 14:41:45 +08:00
b9bce3f2d6 房间热度卡开发-礼物列表调整 2026-01-26 14:07:46 +08:00
7b11279d10 房间热度卡开发-礼物列表调整 2026-01-26 11:51:59 +08:00
509a0cf78f Merge remote-tracking branch 'origin/develop' into develop 2026-01-26 11:31:07 +08:00
ec7f58b365 房间热度卡开发-礼物列表调整 2026-01-26 11:31:02 +08:00
1325a5ad12 进入房间 2026-01-26 11:28:43 +08:00
4974ea58b9 进入房间 2026-01-26 11:08:47 +08:00
6af3558660 房间热度卡开发-礼物列表调整 2026-01-26 10:58:07 +08:00
41f12df16c 房间热度卡开发-礼物列表调整 2026-01-26 10:55:02 +08:00
f8fe14e11c 房间关系 2026-01-26 10:49:49 +08:00
5970783482 js支付 2026-01-26 10:27:28 +08:00
f137d03073 js支付 2026-01-26 10:24:42 +08:00
be987c25b5 js支付 2026-01-26 10:21:58 +08:00
68b0c3e102 js支付 2026-01-26 10:16:57 +08:00
5d05a35d89 js支付 2026-01-26 10:14:54 +08:00
c15bd51d2a js支付 2026-01-26 10:10:30 +08:00
654f4b3281 js支付 2026-01-26 10:06:51 +08:00
83d2e9ff8d js支付 2026-01-26 10:04:47 +08:00
4c9393ed25 js支付 2026-01-26 10:00:41 +08:00
e32a3fa46f js支付 2026-01-26 09:56:52 +08:00
71120548cb 房间热度卡开发-调试 2026-01-26 09:55:06 +08:00
4d991bc6cd 房间热度卡开发-调试 2026-01-26 09:51:11 +08:00
0b3159f22e 房间热度卡开发-调试 2026-01-23 19:05:31 +08:00
67b2e8801a 房间热度卡开发-调试 2026-01-23 19:00:12 +08:00
6252df348e 房间热度卡开发-调试 2026-01-23 18:27:48 +08:00
41a2799e41 房间热度卡开发-调试 2026-01-23 17:52:50 +08:00
d91252b4d0 房间热度卡开发-调试 2026-01-23 17:41:40 +08:00
e2bce9f831 房间热度卡开发-调试 2026-01-23 17:36:02 +08:00
76bd5de916 房间热度卡开发-调试 2026-01-23 17:33:26 +08:00
10d86207ba 房间热度卡开发-调试 2026-01-23 17:20:31 +08:00
62bd53e386 房间热度卡开发-调试 2026-01-23 16:15:05 +08:00
64db503c1f 房间热度卡开发-调试 2026-01-23 15:21:41 +08:00
d721c5290d 房间热度卡开发-调试 2026-01-23 15:15:30 +08:00
4f6e40f4f6 房间热度卡开发-调试 2026-01-23 15:10:23 +08:00
d2a7b6f4d8 房间热度卡开发-调试 2026-01-23 15:08:20 +08:00
afbaafbb7c 房间热度卡开发。 2026-01-23 15:06:30 +08:00
b6297117a1 房间热度卡开发。 2026-01-23 15:02:06 +08:00
b44227cebc 房间热度卡开发。 2026-01-23 14:18:06 +08:00
84a2cdf67c 后台任务列表搜索修改 2026-01-23 14:15:05 +08:00
0eb1d25bb3 房间热度卡开发。 2026-01-23 14:08:37 +08:00
743c4847ec 房间密码 2026-01-23 12:15:21 +08:00
ebb8416d2a 房间密码 2026-01-23 12:12:47 +08:00
fa0fd7c28b 房间密码 2026-01-23 12:10:59 +08:00
1b7ecc29d8 房间密码 2026-01-23 12:10:19 +08:00
d341107508 房间密码 2026-01-23 12:00:08 +08:00
29db4c75e0 Merge remote-tracking branch 'origin/develop' into develop 2026-01-23 11:46:35 +08:00
c215815f28 后台任务类型列表接口 2026-01-23 11:46:18 +08:00
580d204711 房间密码 2026-01-23 11:39:09 +08:00
fcb07c9a4a 去除不用的任务代码 2026-01-23 11:08:45 +08:00
c8f1496250 房间密码 2026-01-23 10:59:47 +08:00
20c8a945bc 时长任务5,10,15分钟 变更为 “改为在热门房间在线 2026-01-23 10:44:12 +08:00
222fbec635 礼物墙 2026-01-23 10:37:39 +08:00
e2f25286c6 Jsapi支付 2026-01-23 10:35:46 +08:00
5bde9a9de4 礼物墙 2026-01-23 10:29:27 +08:00
3d9432e4f5 每日抢到五个红包(0/5) 2026-01-23 10:27:33 +08:00
dc4dc3001f 礼物墙 2026-01-23 10:13:15 +08:00
5f0b1a0fcb 礼物墙 2026-01-23 09:17:42 +08:00
e41fa19f13 提现错误回滚 2026-01-22 17:38:06 +08:00
91ce0662df 房间主持列表接口提交 2026-01-22 17:25:48 +08:00
8f0f6110d0 cp表达超过24小时 就失效了 2026-01-22 16:25:47 +08:00
7354fae9ac 房间主持列表接口提交 2026-01-22 16:06:10 +08:00
3af811cfcd cp表达超过24小时 就失效了 2026-01-22 15:41:22 +08:00
29da1bad45 Merge remote-tracking branch 'origin/develop' into develop 2026-01-22 15:31:49 +08:00
9d0daea74a 房间主持列表接口提交 2026-01-22 15:31:42 +08:00
344dc4f30a cp表达超过24小时 就失效了 2026-01-22 15:30:23 +08:00
46f644aacf 礼物墙 2026-01-22 15:12:08 +08:00
d636d64fe7 bug修改 2026-01-22 11:49:16 +08:00
10f7735af9 bug修改 2026-01-22 11:37:44 +08:00
08df1b687a 钱包相关 2026-01-22 11:35:02 +08:00
029c3b2fc2 Merge remote-tracking branch 'origin/develop' into develop 2026-01-22 11:29:46 +08:00
f304d233a6 bug修改 2026-01-22 11:29:35 +08:00
44ae62e05b 房间营业时间后台修改 2026-01-22 09:58:56 +08:00
d708741885 任务修改 2026-01-22 09:21:49 +08:00
585451739f 任务修改 2026-01-21 19:19:44 +08:00
993298694b 后台上线后bug修改 2026-01-21 18:26:03 +08:00
3597f8f864 房间流水 2026-01-21 17:59:48 +08:00
d4ce0399ad 33 2026-01-21 17:47:39 +08:00
70be1e7603 营业时间过后 不踢人了 2026-01-21 17:21:19 +08:00
23f452ab63 营业时间过后 不踢人了 2026-01-21 15:43:07 +08:00
cef5518fbf 在房间麦上 不让进入其他房间 2026-01-21 15:24:34 +08:00
d7d221bc83 历史足迹 2026-01-21 14:50:51 +08:00
6e1f401d46 银行卡回显 2026-01-21 11:44:59 +08:00
339899ac61 pk任务 2026-01-21 11:32:48 +08:00
5c065c0950 pk任务 2026-01-21 10:32:39 +08:00
88a17988ae 后台bug修改 2026-01-21 10:02:14 +08:00
78635bae05 新需求:PK任务 提交 2026-01-20 22:14:28 +08:00
03728ff399 新需求:PK任务 提交 2026-01-20 21:51:24 +08:00
f0519ac0f4 新需求:PK任务 提交 2026-01-20 21:46:29 +08:00
51e2bc876a 新需求:PK任务 提交 2026-01-20 21:34:05 +08:00
7bed41e76a 新需求:PK任务 提交 2026-01-20 21:05:46 +08:00
66790e84f7 新需求:PK任务 提交 2026-01-20 20:55:56 +08:00
0b9608d1d9 pk任务 2026-01-20 20:48:16 +08:00
7e160790bc 新需求:PK任务 提交 2026-01-20 20:45:10 +08:00
59c65a2aff pk任务 2026-01-20 20:15:55 +08:00
41adc08f7f pk任务 2026-01-20 20:14:45 +08:00
5ae27e5e79 pk任务 2026-01-20 20:12:44 +08:00
1a066e41de 新需求:PK任务 提交 2026-01-20 20:10:09 +08:00
4d904bc64d pk任务 2026-01-20 19:58:31 +08:00
11e58e7430 pk任务 2026-01-20 19:48:37 +08:00
70e6582bc4 pk任务 2026-01-20 19:38:11 +08:00
b0b22f2f57 pk任务 2026-01-20 19:35:22 +08:00
a1e676e6e3 交友房送全麦 2026-01-20 19:25:57 +08:00
53e83536e7 新需求:PK任务 提交 2026-01-20 19:10:55 +08:00
4b00b49b9c 营业时间 2026-01-20 19:09:56 +08:00
3928cad868 pk发起者要在9号麦 2026-01-20 19:02:37 +08:00
feb2174855 pk发起者要在9号麦 2026-01-20 18:57:27 +08:00
95350e3f7d 新需求:PK任务 提交 2026-01-20 18:48:01 +08:00
0866d9c4fd pk发起者要在9号麦 2026-01-20 18:38:27 +08:00
c49cd9d9fd pk发起者要在9号麦 2026-01-20 18:29:17 +08:00
5c6ea83b47 pk发起者要在9号麦 2026-01-20 18:25:25 +08:00
3cfc391a5d 新需求:PK任务 提交 2026-01-20 18:21:46 +08:00
f37328f8bd PK麦上 不能串房间 2026-01-20 17:45:47 +08:00
a3ebb5d3f2 PK麦上 不能串房间 2026-01-20 17:42:35 +08:00
e6762b6b8b PK麦上 不能串房间 2026-01-20 17:38:52 +08:00
02f48dc0eb PK麦上 不能串房间 2026-01-20 17:29:38 +08:00
ae697a540f PK麦上 不能串房间 2026-01-20 17:27:40 +08:00
cb8b6798b9 测试清除房间首页热度值 2026-01-20 17:20:19 +08:00
973953aae6 营业时间 到了 用户退出房间 2026-01-20 17:16:32 +08:00
6cf6d2a1ca 营业时间 到了 用户退出房间 2026-01-20 17:11:12 +08:00
9a7b6f56ac 营业时间 到了 用户退出房间 2026-01-20 17:05:20 +08:00
7d18d6102d 营业时间 到了 用户退出房间 2026-01-20 15:45:42 +08:00
d95e799494 营业时间 到了 用户退出房间 2026-01-20 15:44:05 +08:00
e977d4b4f1 营业时间 到了 用户退出房间 2026-01-20 15:37:45 +08:00
7ac9879702 Merge remote-tracking branch 'origin/develop' into develop 2026-01-20 15:31:38 +08:00
252de5c9e2 新需求:爵位管理后台增加赠送功能 2026-01-20 15:31:30 +08:00
72 changed files with 4583 additions and 661 deletions

View File

@@ -675,23 +675,45 @@ class Activities extends adminApi
$page_limit = input('page_limit', 30);
$user_id = input('user_id', '');
$gift_bag_id = input('gift_bag_id', 1);
$begin_time = input('begin_time', '');
$end_time = input('end_time', '');
$where = [];
if($user_id){
$where['user_id'] = $user_id;
$where['a.user_id'] = $user_id;
}
if($gift_bag_id){
$where['gift_bag_id'] = $gift_bag_id;
$where['a.gift_bag_id'] = $gift_bag_id;
}else{
$where['a.gift_bag_id'] = ['in', [1,2]];
}
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
if($begin_time){
$where['a.createtime'] = ['>=', strtotime($begin_time)];
}
if($end_time){
$where['a.createtime'] = ['<=', strtotime($end_time)];
}
if($begin_time && $end_time){
$where['a.createtime'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
}
$count = db::name('vs_gift_bag_receive_log')->alias('a')->where($where)->count();
$lists_data = db::name('vs_gift_bag_receive_log')
->alias('a')
->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
->join('vs_gift c', 'a.gift_id=c.gid')
->field('a.*,b.name,b.type,b.quantity,b.foreign_id,c.gift_price,b.name')
->where($where)->page($page, $page_limit)->order("id desc")->select();
$lists = [];
foreach ($lists_data as $key => $value) {
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
$user = db::name('user')->where('id',$value['user_id'])->find();
$lists[$key]['id'] = $value['id'];
$lists[$key]['user_id'] = $value['user_id'];
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
$lists[$key]['user_name'] = $user['user_code'].'-'.$user['nickname'];
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
$lists[$key]['money'] = $gift_bag['money'];
//礼物
$lists[$key]['gift'] = $value['name']."*".$value['quantity'];
$lists[$key]['gift_price'] = $value['gift_price'] * $value['quantity'];
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
}
$return_data = [

View File

@@ -188,9 +188,9 @@ class BlindBox extends adminApi
if($type){
$where['type'] = $type;
}
if($label){
$where['label'] = $label;
}
// if($label){
// $where['label'] = $label;
// }
$list = db::name("vs_gift")->where($where)->order('sort','asc')->select();
$list_data = [];
foreach ($list as $k=>$v){
@@ -537,7 +537,7 @@ class BlindBox extends adminApi
if($activities_id == ""){
$activities_id = 4;
}
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id,'status'=>1])->select();
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id])->select();
return V(1,"成功", $bag_list);
}
//--------------------------盲盒转盘与巡乐会-------------------------------------------------------

View File

@@ -383,6 +383,9 @@ class Decorate extends adminApi
}else{
$return_list[$k]['name'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('title');
}
if(in_array($v['type'],[12,13])){
$return_list[$k]['name'] = $return_list[$k]['name'] ." * ".$v['num']."";
}
$return_list[$k]['base_image'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('base_image');
$return_list[$k]['is_using'] = $v['is_using'];
$return_list[$k]['is_using_str'] = $v['is_using']==1?"使用中":"未使用";

View File

@@ -90,6 +90,7 @@ class Guild extends adminApi
$list[$k]['status_str'] = $v['status'] == 1 ? '正常' : '解散';
$list[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
$list[$k]['updatetime'] = date('Y-m-d H:i:s',$v['updatetime']);
$list[$k]['delete_time'] = $v['delete_time'] ? date('Y-m-d H:i:s',$v['delete_time']) : "";
$list[$k]['user_id'] = $user['user_code']??"";
$list[$k]['intro'] = $v['intro'];
//幸运币流水
@@ -447,9 +448,9 @@ class Guild extends adminApi
$rum_lists[$k]['charm_level']=$user_info['charm_level']??0;
$rum_lists[$k]['wealth_level']=$user_info['wealth_level']??0;
//用户流水
$consumption_sql = db::name('vs_user_money_log')
$consumption_sql = db::name('user_coin_log')
->whereIn('change_type',$coin_consumption_type_array)
->where(['money_type'=>1,'user_id' => $v['user_id']]);
->where(['user_id' => $v['user_id']]);
if($v['quit_type'] == 3){
$consumption_sql->where(['createtime'=>['<=',$v['delete_time']]]);
$consumption_sql->where(['createtime'=>['>=',$v['createtime']]]);
@@ -699,6 +700,11 @@ class Guild extends adminApi
//更新公会人数
db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
//拉用户进入工会群聊
if($merge_guild_id<=95){
$merge_guild_id = "g".$merge_guild_id;
}else{
$merge_guild_id = $merge_guild_id;
}
$rid = 'g'.$merge_guild_id;
$reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
}
@@ -708,6 +714,11 @@ class Guild extends adminApi
return V(0,"失败");
}
//解散群
if($guild_id<=95){
$guild_id = "g".$guild_id;
}else{
$guild_id = $guild_id;
}
model('api/Tencent')->delete_group('g'.$guild_id);
db::commit();
return V(1,"成功");

View File

@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
use app\admin\model\AdminLog;
use app\common\controller\adminApi;
use app\common\library\GiftTableManager;
use think\Config;
use think\Db;
use think\Hook;
@@ -162,11 +163,19 @@ class Index extends adminApi
$day_time_end = strtotime(date('Y-m-') . $i . ' 23:59:59');
$gift_money[$i]['time'] = date('Y-m-') . $i;
//总礼物打赏值
$gift_money[$i]['gift_total_day'] = Db::name('vs_give_gift')->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
$tables = GiftTableManager::getTablesByTimeRange(
$day_time,
$day_time_end
);
$table_name = $tables[0];
//表前缀
$table_prefix = config('database.prefix');
$table_name = str_replace($table_prefix, '', $table_name);
$gift_money[$i]['gift_total_day'] = Db::name($table_name)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
//购买礼物打赏价值
$gift_money[$i]['gift_buy_day'] = Db::name('vs_give_gift')->where('type',1)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
$gift_money[$i]['gift_buy_day'] = Db::name($table_name)->where('type',1)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
//背包礼物打赏价值
$gift_money[$i]['gift_backpack_day'] = Db::name('vs_give_gift')->where('type',2)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
$gift_money[$i]['gift_backpack_day'] = Db::name($table_name)->where('type',2)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
}
}

View File

@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
use app\admin\model\AdminLog;
use app\common\controller\adminApi;
use think\Cache;
use think\Config;
use think\Db;
use think\Hook;
@@ -16,18 +17,20 @@ use think\Validate;
*/
class Lottery extends adminApi
{
// Redis实例
private $redis;
protected $noNeedLogin = [];
protected $noNeedRight = [];
public function _initialize()
{
parent::_initialize();
}
/*
* 配置列表
*/
public function config_list(){
$list = db::name("bb_lottery_config")->order('sort desc')->select();
$list = db::name("bb_lottery_config")->where(['delete_time' => 0])->order('sort desc')->select();
$list_data = [];
foreach ($list as $k=>$v){
$list_data[$k]['id'] = $v['id'];
@@ -43,13 +46,114 @@ class Lottery extends adminApi
* 配置设置
*/
public function config_set(){
$bb_lottery_config = Db::name('bb_lottery_config')->column('value', 'key');
$small_pool_trigger_times = $bb_lottery_config['small_pool_trigger_times'];//初级开奖的累计次数
$lottery_rate = $bb_lottery_config['lottery_rate'];//初级最大爆币率
$small_pool_trigger_times_5 = $bb_lottery_config['small_pool_trigger_times_5'];//中级开奖的累计次数
$lottery_rate_5 = $bb_lottery_config['lottery_rate_5'];//中级最大爆币率
$small_pool_trigger_times_10 = $bb_lottery_config['small_pool_trigger_times_10'];//高级最大爆币率
$lottery_rate_10 = $bb_lottery_config['lottery_rate_10'];//高级最大爆币率
$params = $this->request->post();
$small_type = 0;
$small_type_5 = 0;
$small_type_10 = 0;
foreach ($params as $k=>$v){
$data = [
'value'=>$v,
];
db::name("bb_lottery_config")->where(['key'=>$k])->update($data);
if($k=='small_pool_trigger_times'){
if($v != $small_pool_trigger_times){
$small_type = 1;
}
}
if($k=='lottery_rate'){
if($v != $lottery_rate){
$small_type = 1;
}
}
if($k=='small_pool_trigger_times_5'){
if($v != $small_pool_trigger_times_5){
$small_type_5 = 1;
}
}
if($k=='lottery_rate_5'){
if($v != $lottery_rate_5){
$small_type_5 = 1;
}
}
if($k=='small_pool_trigger_times_10'){
if($v != $small_pool_trigger_times_10){
$small_type_10 = 1;
}
}
if($k=='lottery_rate_10'){
if($v != $lottery_rate_10){
$small_type_10 = 1;
}
}
}
$this->redis = Cache::store('redis')->handler();
if($small_type==1){
$prize_amount = $this->redis->get('lottery:small_pool:total_gold');
Db::name('bb_lottery_winner_record')->insert([
'uid' => 0,
'prize_type' => 1,
'prize_amount' => $prize_amount,
'pool_amount' => $prize_amount,
'ratio' => 100,
'release_amount' => $prize_amount,
'create_time' => time(),
'status' => 0 // 未发放
]);
//修改开启下一轮
$dd =$this->redis->get('lottery:small_pool:round');
$this->redis->set('lottery:small_pool:round', $dd+1);
$this->redis->set('lottery:small_pool:total_times',0);
$this->redis->set('lottery:small_pool:total_gold',0);
}
if($small_type_5==1){
$prize_amount_5 = $this->redis->get('lottery:small_pool:total_gold_5');
Db::name('bb_lottery_winner_record')->insert([
'uid' => 0,
'prize_type' => 3,
'prize_amount' => $prize_amount_5,
'pool_amount' => $prize_amount_5,
'ratio' => 100,
'release_amount' => $prize_amount_5,
'create_time' => time(),
'status' => 0 // 未发放
]);
//修改开启下一轮
$dd5 =$this->redis->get('lottery:small_pool:round_5');
$this->redis->set('lottery:small_pool:round_5', $dd5+1);
$this->redis->set('lottery:small_pool:total_times_5',0);
$this->redis->set('lottery:small_pool:total_gold_5',0);
}
if($small_type_10==1){
$prize_amount_10 = $this->redis->get('lottery:small_pool:total_gold_10');
Db::name('bb_lottery_winner_record')->insert([
'uid' => 0,
'prize_type' => 4,
'prize_amount' => $prize_amount_10,
'pool_amount' => $prize_amount_10,
'ratio' => 100,
'release_amount' => $prize_amount_10,
'create_time' => time(),
'status' => 0 // 未发放
]);
//修改开启下一轮
$dd_10 =$this->redis->get('lottery:small_pool:round_10');
$this->redis->set('lottery:small_pool:round_10', $dd_10+1);
$this->redis->set('lottery:small_pool:total_times_10',0);
$this->redis->set('lottery:small_pool:total_gold_10',0);
}
return V(1,"成功");
}
@@ -61,7 +165,18 @@ class Lottery extends adminApi
$page_limit = input('page_limit', 30);
$stime = input('stime', '');
$etime = input('etime', '');
$pool_type = input('pool_type', '1');
$user_code = input('user_code');
if($user_code){
$userId = db::name('user')->where(['user_code'=>$user_code])->value('id');
if($userId){
$where['uid'] = $userId;
}else{
$where['uid'] = '1';
}
}
$where = [];
$where['prize_type'] = $pool_type;
if($stime!==""){
$where['create_time'] = ['>=', strtotime($stime)];
}
@@ -72,16 +187,39 @@ class Lottery extends adminApi
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
}
$count = db::name('bb_lottery_winner_record')->where($where)->count();
$lists_data = db::name('bb_lottery_winner_record')->field('id,uid as user_id,prize_type,prize_amount,pool_amount,ratio,release_amount,status,create_time as createtime')->where($where)->page($page, $page_limit)->order("id desc")->select();
$lists_data = db::name('bb_lottery_winner_record')
->field('id,uid as user_id,prize_type,prize_amount,pool_amount,ratio,release_amount,status,create_time as createtime')
->where($where)->page($page, $page_limit)->order("id desc")->select();
foreach ($lists_data as $k=>$v){
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
$lists_data[$k]['user_code'] = $user_info['user_code']??"";
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
if($v['user_id'] > 0){
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
$lists_data[$k]['user_code'] = $user_info['user_code']??"";
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
}else{
$lists_data[$k]['user_code'] = "";
$lists_data[$k]['nickname'] = "后台重置,全部释放";
}
//奖项类型1-小奖 2-大奖
$lists_data[$k]['prize_type_str'] = $v['prize_type']==1?"小奖":"大奖";
if($v['prize_type']==4){
$lists_data[$k]['prize_type_str'] = "高级奖";
$gift_price = 10;
}elseif ($v['prize_type']==2){
$gift_price = 1;
$lists_data[$k]['prize_type_str'] = "大奖";
}elseif ($v['prize_type']==3){
$gift_price = 5;
$lists_data[$k]['prize_type_str'] = "中级奖";
}else{
$gift_price = 1;
$lists_data[$k]['prize_type_str'] = "小奖";
}
//状态1-已发放 0-未发放'
$lists_data[$k]['status_str'] = $v['status']==1?"已发放":"未发放";
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
$lists_data[$k]['prize_amount'] = floor($v['prize_amount']);
$lists_data[$k]['beilv'] = floor($v['prize_amount'] / $gift_price);
}
$return_data = [
'page' =>$page,
@@ -98,23 +236,48 @@ class Lottery extends adminApi
* 实时统计
*/
public function realtime_statistics(){
$pool_type = input('pool_type', '1');
$bb_config = db::name('bb_lottery_config')->field('key,value')->select();
$bb_config = array_column($bb_config, null, 'key');
// 循环奖池进度
//最新轮次
$latest_times = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1])->max('times');
$pool_progress = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
$pool_total_amount = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
//获取配置表中奖池配置
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times']['value']."(".$pool_total_amount."金币)";
if($pool_type == 4){
$latest_times = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1])->max('times');//最新轮次
$pool_progress = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
$pool_total_amount = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
//获取配置表中奖池配置
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times_10']['value']."(".$pool_total_amount."金币)";
//最近中奖用户
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>4])->order('id desc')->find();
//平台累计收入
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>4])->sum('release_amount');
}elseif($pool_type == 3){
$latest_times = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1])->max('times');//最新轮次
$pool_progress = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
$pool_total_amount = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
//获取配置表中奖池配置
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times_5']['value']."(".$pool_total_amount."金币)";
//最近中奖用户
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>3])->order('id desc')->find();
//平台累计收入
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>3])->sum('release_amount');
}else{
$latest_times = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1])->max('times');//最新轮次
$pool_progress = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
$pool_total_amount = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
//获取配置表中奖池配置
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times']['value']."(".$pool_total_amount."金币)";
//最近中奖用户
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>1])->order('id desc')->find();
//平台累计收入
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>1])->sum('release_amount');
}
//蓄水池当前金额
$big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
$bigAddGold = Db::name('bb_lottery_pool_flow')
->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])
->sum('amount') ?: 0;
//最近中奖用户
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1])->order('id desc')->find();
// $big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
// $bigAddGold = Db::name('bb_lottery_pool_flow')->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])->sum('amount') ?: 0;
$bigAddGold = 0;
if($last_winner_user_id){
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
$last_winner_user_text = "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 ".$last_winner_user_id['ratio']."%)";
@@ -123,7 +286,8 @@ class Lottery extends adminApi
}
//平台累计收入
$platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
// $platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
$return_data=[
'pool_progress' => $pool_progress_str,
'pool_amount_now' => ($bigAddGold)."金币 ".(($bigAddGold)/$bb_config['big_pool_threshold']['value'])."%)",
@@ -132,4 +296,67 @@ class Lottery extends adminApi
];
return V(1,"成功", $return_data);
}
/*
* 抽奖记录
*/
public function pool_flow_list(){
$page = input('page', 1);
$page_limit = input('page_limit', 30);
$stime = input('stime', '');
$etime = input('etime', '');
$pool_type = input('pool_type', '1');
$user_code = input('user_code');
if($user_code){
$userId = db::name('user')->where(['user_code'=>$user_code])->value('id');
if($userId){
$where['uid'] = $userId;
}else{
$where['uid'] = '1';
}
}
if($pool_type == 4){
$table = 'bb_lottery_gift_record_10';
}
elseif($pool_type == 3){
$table = 'bb_lottery_gift_record_5';
}
else{
$table = 'bb_lottery_gift_record';
}
$where = [];
if($stime!==""){
$where['create_time'] = ['>=', strtotime($stime)];
}
if($etime!==""){
$where['create_time'] = ['<=', strtotime($etime)];
}
if($stime!=="" && $etime!==""){
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
}
$count = db::name($table)->where($where)->count();
$lists_data = db::name($table)
->field('id,send_uid,recv_uid,gift_id,gift_gold,recv_gold,small_pool_add,remark,create_time as createtime')
->where($where)
->order("id desc")
->page($page, $page_limit)->select();
foreach ($lists_data as $k=>$v){
$send_user_info = db::name('user')->field('nickname,user_code')->where(['id'=>$v['send_uid']])->find();
$recv_user_info = db::name('user')->field('nickname,user_code')->where(['id'=>$v['recv_uid']])->find();
$lists_data[$k]['send_nickname'] = $send_user_info['user_code']."-".$send_user_info['nickname'];
$lists_data[$k]['recv_nickname'] = $recv_user_info['user_code']."-".$recv_user_info['nickname'];
$lists_data[$k]['gift_name'] = db::name('vs_gift')->where(['gid'=>$v['gift_id']])->value('gift_name');
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
}
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
'count' => $count,
'lists' => $lists_data,
'total_data' => [
]
];
return V(1,"成功", $return_data);
}
}

View File

@@ -0,0 +1,146 @@
<?php
namespace app\adminapi\controller;
use app\admin\model\AdminLog;
use app\common\controller\adminApi;
use think\Cache;
use think\Config;
use think\Db;
class Monster extends adminApi
{
//获取列表
public function get_monster_list()
{
$order = input('order', 'id');
$sort = input('sort', 'desc');
$page = input('page', 1);
$limit = input('limit', 20);
$reslut = model('Monster')->get_monster_list($order, $sort, $page, $limit);
$data = [];
$data['code'] = 0;
$data['msg'] = '获取成功';
$data['count'] = $reslut['data']['count'];
$data['data'] = $reslut['data']['list'];
return V(1,"成功", $data);
}
//获取详情
public function get_monster_info()
{
$id = input('id', 0);
$reslut = model('Monster')->get_monster_info($id);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//编辑
public function edit_monster()
{
$data['id'] = input('id', 0);
$data['gid'] = input('gid', 0);
$data['num'] = input('num', 0);
$data['type_name'] = input('type_name', 0);
$data['multiple'] = input('multiple', 0);
$reslut = model('Monster')->edit_monster($data);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//获取礼物列表
public function get_gift_list()
{
$reslut = model('Monster')->get_gift_list();
$data = [];
$data['code'] = 0;
$data['msg'] = '获取成功';
$data['count'] = $reslut['data']['count'];
$data['data'] = $reslut['data']['list'];
return V(1,"成功", $data);
}
//获取列表
public function get_monster_multiple_list()
{
$order = input('order', 'id');
$sort = input('sort', 'desc');
$page = input('page', 1);
$limit = input('limit', 20);
$reslut = model('Monster')->get_monster_multiple_list($order, $sort, $page, $limit);
$data = [];
$data['code'] = 0;
$data['msg'] = '获取成功';
$data['count'] = $reslut['data']['count'];
$data['data'] = $reslut['data']['list'];
return V(1,"成功", $data);
}
//获取详情
public function get_monster_multiple_info()
{
$id = input('id', 0);
$reslut = model('Monster')->get_monster_multiple_info($id);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//编辑
public function edit_monster_multiple()
{
$data['id'] = input('id', 0);
$data['multiple'] = input('multiple', 0);
$reslut = model('Monster')->edit_monster_multiple($data);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//获取列表
public function get_monster_log(){
$order = input('order', 'id');
$sort = input('sort', 'desc');
$page = input('page', 1);
$limit = input('limit', 20);
$reslut = model('Monster')->get_monster_log($order, $sort, $page, $limit);
$data = [];
$data['code'] = 0;
$data['msg'] = '获取成功';
$data['count'] = $reslut['data']['count'];
$data['data'] = $reslut['data']['list'];
$data['totalRow'] = $reslut['data']['totalRow'];
return V(1,"成功", $data);
}
//获取列表
public function get_user_monster_log(){
$mid = input('mid', 0);
$order = input('order', 'id');
$sort = input('sort', 'desc');
$page = input('page', 1);
$limit = input('limit', 20);
$reslut = model('Monster')->get_user_monster_log($mid, $order, $sort, $page, $limit);
$data = [];
$data['code'] = 0;
$data['msg'] = '获取成功';
$data['count'] = $reslut['data']['count'];
$data['data'] = $reslut['data']['list'];
return V(1,"成功", $data);
}
//获取列表
public function get_user_monster_win_log(){
$mid = input('mid', 0);
$order = input('order', 'id');
$sort = input('sort', 'desc');
$page = input('page', 1);
$limit = input('limit', 20);
$reslut = model('Monster')->get_user_monster_win_log($mid, $order, $sort, $page, $limit);
$data = [];
$data['code'] = 0;
$data['msg'] = '获取成功';
$data['count'] = $reslut['data']['count'];
$data['data'] = $reslut['data']['list'];
return V(1,"成功", $data);
}
}

View File

@@ -414,4 +414,19 @@ class Nobility extends adminApi
return V(0, "删除失败");
}
}
//爵位赠送
public function give_nobility(){
$user_code = input('user_code', '');
$lid = input('lid', '');
$user_id = db::name('user')->where('delete_time', 0)->where('user_code', $user_code)->value('id');
if (empty($user_id)) {
return V(0, "请选择用户");
}
if (empty($lid)) {
return V(0, "请选择爵位");
}
$reslut = model('api/Nobility')->buyNobility($user_id,$lid,1);
return V($reslut['code'],$reslut['msg'], null);
}
}

View File

@@ -343,7 +343,12 @@ class Room extends adminApi
$count = db::name($this->relation)->where($where)->count();
$lists = db::name($this->relation)->where($where)->page($page, $page_limit)->select();
foreach ($lists as $key => $value) {
$lists[$key]['type_str'] = model('Room')->relation_type[$value['type']];
if($value['type'] > 0){
$lists[$key]['type_str'] = model('Room')->relation_type[$value['type']];
}else{
$lists[$key]['type_str'] = '无关系';
}
$lists[$key]['is_open_movie'] = $value['is_open_movie']==1?'是':'否';
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
}
@@ -1003,6 +1008,14 @@ class Room extends adminApi
if($type_id == 9){
$data['label_id'] = 6;
}
$start_time = input('start_time', '');//营业开始时间
if($start_time){
$data['start_time'] = $start_time;
}
$end_time = input('end_time', '');//营业结束时间
if($end_time){
$data['end_time'] = $end_time;
}
$data['updatetime'] = time();
$res = db::name('vs_room')->where('id',$room_id)->update($data);
if($res){
@@ -2018,4 +2031,70 @@ class Room extends adminApi
return V(1, "成功", $return_data);
}
// 房间主持人列表
public function room_host_list(){
$page = input('page', 1);
$page_limit = input('page_limit', 10);
$room_id = input('room_id', '');
if(empty($room_id)){
return V(0, "房间ID不能为空");
}
$count = db::name("vs_room_host")->where(['room_id'=>$room_id])->count();
$room_host_lists = db::name("vs_room_host")->where(['room_id'=>$room_id])->order('createtime desc')->page($page, $page_limit)->select();
if($room_host_lists){
foreach ($room_host_lists as $key => $value){
$room_host_lists[$key]['type_str'] = $value['type'] == 1 ? '主持' : '管理'; //1主持 2管理
$room_host_lists[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
$room_host_lists[$key]['avatar'] = db::name('user')->where(['id'=>$value['user_id']])->value('avatar');
$room_host_lists[$key]['user_code'] = db::name('user')->where(['id'=>$value['user_id']])->value('user_code');
$room_host_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
//主持是否在买上
$roop_pit_9 = db::name('vs_room_pit')->where(['room_id'=>$room_id, 'user_id'=>$value['user_id'],'pit_number'=>9])->value('id');
$room_host_lists[$key]['is_on_mic'] = $roop_pit_9 ? 1 : 0;
}
}
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
'count' => $count,
'lists' => $room_host_lists
];
return V(1, "成功", $return_data);
}
//房间幸运值流水详情
public function room_luck_list(){
$page = input('page', 1);
$page_limit = input('page_limit', 10);
$room_id = input('room_id', '');
if(empty($room_id)){
return V(0, "房间ID不能为空");
}
$count = db::name("vs_room_luck_value")->where(['room_id'=>$room_id])->count();
$room_host_lists = db::name("vs_room_luck_value")
->where(['room_id'=>$room_id])
->order('createtime desc')
->page($page, $page_limit)->select();
if($room_host_lists){
foreach ($room_host_lists as $key => $value){
$room_host_lists[$key]['send_nickname'] = db::name('user')->where(['id'=>$value['send_uid']])->value('nickname');
$room_host_lists[$key]['send_avatar'] = db::name('user')->where(['id'=>$value['send_uid']])->value('avatar');
$room_host_lists[$key]['send_user_code'] = db::name('user')->where(['id'=>$value['send_uid']])->value('user_code');
$room_host_lists[$key]['recv_nickname'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('nickname');
$room_host_lists[$key]['recv_avatar'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('avatar');
$room_host_lists[$key]['recv_user_code'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('user_code');
$room_host_lists[$key]['gift_name'] = db::name('vs_gift')->where(['gid'=>$value['gift_id']])->value('gift_name');
$room_host_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
}
}
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
'count' => $count,
'lists' => $room_host_lists
];
return V(1, "成功", $return_data);
}
}

View File

@@ -133,7 +133,10 @@ class Statistical extends adminApi
if(empty($tables)){
$tables[0] = "fa_vs_give_gift";
}
$table_name = substr($tables[0], 3);//截取可查询的表名
$table_name = $tables[count($tables)-1];
//表前缀
$table_prefix = config('database.prefix');
$table_name = str_replace($table_prefix, '', $table_name);//截取可查询的表名
$count = db::name($table_name)
->where($where)
->group($group)
@@ -268,7 +271,10 @@ class Statistical extends adminApi
if(empty($tables)){
$tables[0] = "fa_vs_give_gift";
}
$table_name = substr($tables[0], 3);//截取可查询的表名
$table_name = $tables[count($tables)-1];
//表前缀
$table_prefix = config('database.prefix');
$table_name = str_replace($table_prefix, '', $table_name);//截取可查询的表名
//不为空
$where['from'] = 2;
$count = db::name($table_name)
@@ -762,7 +768,7 @@ class Statistical extends adminApi
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
->where(['b.type'=>['in', [1,2]]])
->whereBetween('a.gift_bag_id', [18, 51])
->whereBetween('a.gift_bag_id', [18, 52])
->where($where)
->select();
}else{
@@ -772,7 +778,7 @@ class Statistical extends adminApi
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
->where(['b.type'=>['in', [1,2]]])
->whereBetween('a.gift_bag_id', [18, 51])
->whereBetween('a.gift_bag_id', [18, 52])
->whereBetween('a.createtime', [strtotime($stime), 1767114849])
->where($where)
->select();
@@ -781,7 +787,7 @@ class Statistical extends adminApi
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
->where(['b.type'=>['in', [1,2]]])
->whereBetween('a.gift_bag_id', [18, 51])
->whereBetween('a.gift_bag_id', [18, 52])
->whereBetween('a.createtime', [1767114849, strtotime($etime)])
->where($where)
->select();
@@ -801,7 +807,7 @@ class Statistical extends adminApi
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
->where(['b.type'=>['in', [1,2]]])
->whereBetween('a.gift_bag_id', [18, 51])
->whereBetween('a.gift_bag_id', [18, 52])
->where($where)
->select();
}

View File

@@ -25,16 +25,18 @@ class SysSet extends adminApi
public $configType = [
'1' => '基础设置',
'2' => '登录设置',
// '2' => '登录设置',
'3' => '支付配置',
'4' => '提现设置',
'5' => '推送及IM配置',
// '5' => '推送及IM配置',
// '6' => '每日任务设置',
'7' => '云存储配置',
'7' => '第三方配置',
'8' => '房间配置',
'9' => '弹窗内容设置',
// '9' => '弹窗内容设置',
'10' => '邀请奖励',
'11' => '二级密码',
'12' => '情侣任务设置',
'13' => '趣味活动中',
];
public $noAdminConfigType = [
'1' => '基础设置',

View File

@@ -105,7 +105,7 @@ class SystemMessage extends adminApi
if($receiving_id){
$data['receiving_id'] = $receiving_id;
}else{
$user_list = db::name('user')->field('id')->select();
$user_list = db::name('user')->where('delete_time',0)->where(['sex'=>['<>',0]])->field('id')->select();
$data['receiving_id'] = implode(',', array_column($user_list, 'id'));
}
if($id){

View File

@@ -30,7 +30,7 @@ class Tasks extends adminApi
public function task_list(){
$page = input('page', 1);
$page_limit = input('page_limit', 10);
$seach_task_type = input('seach_task_type', '');
$seach_task_type = input('task_type', '');
$where=[];
if($seach_task_type != ''){
$where['task_type'] = $seach_task_type;
@@ -121,5 +121,12 @@ class Tasks extends adminApi
}
}
/*
* 任务类型列表
*/
public function task_type_list(){
$list = model('api/Tasks')->task_type;
return V(1,"成功", $list);
}
}

View File

@@ -146,6 +146,8 @@ class User extends adminApi
$lists[$key]['user_block_time'] = '';
$lists[$key]['mobile_block_time'] = '';
$lists[$key]['ip_block_time'] = '';
//禁用理由
$lists[$key]['user_block_reason'] = '';
if($is_block_user){
$lists[$key]['is_block_user'] = 1;
if($is_block_user['block_time']==0){
@@ -153,6 +155,7 @@ class User extends adminApi
}else{
$lists[$key]['user_block_time'] = date('Y-m-d H:i:s',$is_block_user['block_time']);
}
$lists[$key]['user_block_reason'] = model('Block')->getBanReason()[$is_block_user['ban_eason']];
}
// if($is_block_mobile){
// $lists[$key]['is_block_mobile'] = 1;
@@ -224,6 +227,15 @@ class User extends adminApi
$type = input('type', 0);
$time = input('time', 0);
$status = input('status', 1);
$ban_eason = input('ban_eason', 0);
$ban_day = input('ban_day', 0);
if(empty($time)){
if(!empty($ban_day)){
$time = date('Y-m-d H:i:s', time() + $ban_day * 86400);
}else{
$time = "";
}
}
$user_info = model('User')->where('id', $user_id)->find();
if(!$user_info){
return V(0, "用户不存在");
@@ -255,10 +267,28 @@ class User extends adminApi
'type_text' => $type_text,
'block_time' => $block_time,
'createtime' => time(),
'ban_eason' => $ban_eason,
'ban_day' => $ban_day,
]);
if (!$res) {
return V(0, "添加失败");
}
//加推送单聊消息
if($block_time){
$content = "您的账号因 含有".model('Block')->getBanReason()[$ban_eason] . "内容 于".date('Y-m-d H:i:s',time())." 被封禁".model('Block')->getBanTime()[$ban_day]." ".date('Y-m-d H:i:s',$block_time)."解封,如对处罚有异议请及时联系管理员申诉";
}else{
$content = "您的账号因 含有".model('Block')->getBanReason()[$ban_eason] . "内容 于".date('Y-m-d H:i:s',time())." 被永久封禁".model('Block')->getBanTime()[$ban_day]." ,请及时联系管理员申诉";
}
$text = [
'MsgType' => 404,
'ToUserId' => $user_id,
'Text' => [
'text' => $content
]
];
//谁发送给谁什么消息是否同步到发送者1是2否消息是否只下发给在线用户 1 是0 否
model('api/Tencent')->user_sendmsg("administrator",$user_id,json_encode($text),2,1);
}else{
if($type ==1) {
$res = model('User')->where('id', $user_id)->update(['status' => 1]);
@@ -282,6 +312,16 @@ class User extends adminApi
TokenLib::delete($token);
return V(1,"成功", null);
}
//封禁理由
public function getBanEason(){
$list = model('Block')->getBanReason();
return V(1,"成功", $list);
}
//封禁时长
public function getBanDay(){
$list = model('Block')->getBanTime();
return V(1,"成功", $list);
}
/*
* 设为官方账号
@@ -820,6 +860,7 @@ class User extends adminApi
$type = input('type', 1);
$type_text = input('type_text', '');
$block_time = input('block_time', 0);
$ban_eason = input('ban_eason', 0);
$admin_id = Session::get('admin_id');
//插入fa_block 表
$res = Db::name('block')->insert([
@@ -828,10 +869,27 @@ class User extends adminApi
'type_text' => $type_text,
'block_time' => strtotime($block_time),
'createtime' => time(),
'ban_eason' => $ban_eason,
]);
if (!$res) {
return V(0, "添加失败");
}
//1账号, 2设备, 3ip 4禁言
if($type == 1){
$user_id = db::name('user')->where('user_code', $type_text)->value('id');
}
if($type == 2){
$user_id = db::name('user')->where('login_device', $type_text)->value('id');
}
if($type == 3){
$user_id = db::name('user')->where('loginip', $type_text)->value('id');
}
if(isset($user_id)){
$token = db::name('user_token')->where('user_id', $user_id)->value('token');
// 删除这个Token使其失效
TokenLib::delete($token);
}
return V(1,"添加成功", null);
}
/*
@@ -1012,4 +1070,76 @@ class User extends adminApi
return V(1, "操作成功");
}
//cp关系列表
public function user_cp_list(){
$user_id = input('user_id', 0);
$page = input('page', 1);
$page_limit = input('page_limit', 30);
if (!$user_id){
return V(0, "参数错误");
}
$count = db::name('user_cp_zone')
->where(['user_id1'=>$user_id])
->whereOr(['user_id2'=>$user_id])
->count();
$list = db::name('user_cp_zone')->where(['user_id1'=>$user_id])->whereOr(['user_id2'=>$user_id])->select();
foreach ($list as $key => $value) {
$user1 = db::name('user')->field('id,nickname,user_code')->where(['id'=>$value['user_id1']])->find();
$user2 = db::name('user')->field('id,nickname,user_code')->where(['id'=>$value['user_id2']])->find();
$list[$key]['user1_nickname'] = $user1['nickname'];
$list[$key]['user1_user_code'] = $user1['user_code'];
$list[$key]['user2_nickname'] = $user2['nickname'];
$list[$key]['user3_user_code'] = $user2['user_code'];
$list[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
$list[$key]['status_str'] = $value['status'] == 1 ? '已建立' : '已取消';
}
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,
'count' => $count,
'lists' => $list
];
return V(1,"成功", $return_data);
}
//用户关系列表
public function user_relation_list(){
$user_id = input('user_id', 0);
$page = input('page', 1);
$page_limit = input('page_limit', 30);
if (!$user_id){
return V(0, "参数错误");
}
$room_auction1 = db::name('vs_room_auction_relation')->alias('a')
->join('user b','a.user_id1 = b.id','left')
->join('user c','a.user_id2 = c.id','left')
->join('vs_relation d','a.relation_id = d.id','left')//关系
->field('a.relation_id,a.cp_room_id,a.id,a.user_id1,a.user_id2,a.updatetime,a.time_day,a.end_time,b.sex as sex1,b.nickname as nickname1,b.avatar as avatar1,c.sex as sex2,c.nickname as nickname2,c.avatar as avatar2,d.name as relation_name,d.icon as image ,a.delete_time')
->where(['a.user_id1' => $user_id,'a.end_time' =>['>',time()]])
->order('a.updatetime desc')
->select();
$room_auction2 = db::name('vs_room_auction_relation')->alias('a')
->join('user b','a.user_id1 = b.id','left')
->join('user c','a.user_id2 = c.id','left')
->join('vs_relation d','a.relation_id = d.id','left')//关系
->field('a.relation_id,a.cp_room_id,a.id,a.user_id1,a.user_id2,a.updatetime,a.time_day,a.end_time,b.sex as sex1,b.nickname as nickname1,b.avatar as avatar1,c.sex as sex2,c.nickname as nickname2,c.avatar as avatar2,d.name as relation_name,d.icon as image,a.delete_time')
->where(['a.user_id2' => $user_id,'a.end_time' =>['>',time()]])
->order('a.updatetime desc')
->select();
$room_auction = array_merge((array)$room_auction1, (array)$room_auction2);
foreach ($room_auction as $key => $value) {
//是否有效
$room_auction[$key]['is_valid'] = $value['delete_time'] ==0 && $value['end_time'] > time() ? 1 : 0;
$room_auction[$key]['end_time'] = date('Y-m-d H:i:s',$value['end_time']);
$room_auction[$key]['add_time'] = date('Y-m-d H:i:s',$value['updatetime']);
}
$return_data = [
'lists' => $room_auction
];
return V(1,"成功", $return_data);
}
}

View File

@@ -18,6 +18,9 @@ class UserCp extends adminApi
->where($where)
->page($page, $page_limit)
->select();
foreach ($list as &$v){
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$return_data = [
'page' =>$page,
'page_limit' => $page_limit,

View File

@@ -0,0 +1,46 @@
<?php
namespace app\adminapi\model;
use think\Model;
use think\Session;
use think\Db;
class Block extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $name = 'block';
// 封禁理由 辱骂、低俗、引流、涉政、黑产、其它
public static $ban_reason = [
'1' => '辱骂',
'2' => '低俗',
'3' => '引流',
'4' => '涉政',
'5' => '黑产',
'0' => '其它',
];
//封禁时长 1天、3天、7天、一个月、永久
public static $ban_time = [
'1' => '1天',
'3' => '3天',
'7' => '7天',
'30' => '一个月',
'0' => '永久',
];
//获取封禁理由
public static function getBanReason(){
return self::$ban_reason;
}
//获取封禁时长
public static function getBanTime(){
return self::$ban_time;
}
}

View File

@@ -0,0 +1,253 @@
<?php
namespace app\adminapi\model;
use think\Db;
use think\Model;
class Monster extends Model
{
//列表
public function get_monster_list($order, $sort, $page = 1, $limit = 20)
{
$list = db::name('Monster')->order($order, $sort)->page($page, $limit)->select();
$total_num = db::name('Monster')->sum('num');
foreach ($list as $k => &$v) {
$gift_info = db::name('vs_gift')->where('gid', $v['gid'])->find();
$v['gift_name'] = $gift_info['gift_name'];
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
$v['gift_price'] = $gift_info['gift_price'];
$v['rate'] = round(($v['num']/$total_num), 6) * 100;
$v['rate'] .= '%';
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
}
$data = [];
$data['count'] = db::name('Monster')->count();
$data['list'] = $list;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//获取礼物列表
public function get_gift_list(){
$map = [];
// $map[] = ['gid', 'not in', [36,37,38]];
$map['type'] = ['=', 2];
// $map['label'] = ['=', 18];
$map['is_show'] = ['=',1];
$map['delete_time'] = ['=', 0];
$list = db::name('vs_gift')->where($map)->order('gift_price asc')->select();
$data = [];
$data['count'] = db::name('vs_gift')->where($map)->count();
$data['list'] = $list;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//编辑
public function edit_monster($data)
{
if (empty($data)) {
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
}
$monster_info = db::name('Monster')->find($data['id']);
if (empty($monster_info)) {
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
}
$map = [];
$map['gid'] = ['=', $data['gid']];
// $map['type'] = ['=', 1];
$map['is_show'] = ['=',1];
$map['delete_time'] = ['=', 0];
$gift_info = db::name('vs_gift')->where($map)->find();
if(!$gift_info){
return ['code' => 0, 'msg' => '配置礼物不存在', 'data' => null];
}
if($monster_info['multiple'] * 10 != $gift_info['gift_price']){
return ['code' => 0, 'msg' => '配置礼物的价格必须为倍数的10倍', 'data' => null];
}
Db::startTrans();
try {
$update_data = [];
$update_data['type_name'] = $data['type_name'];
if($data['multiple']){
$update_data['multiple'] = $data['multiple'];
}
$update_data['gid'] = $data['gid'];
$update_data['num'] = $data['num'];
$update_data['updatetime'] = time();
$reslut = db::name('Monster')->where(['id' => $data['id']])->update($update_data);
if (!$reslut) {
Db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
Db::commit();
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
} catch (\Exception $e) {
// 回滚事务
dump($e);
Db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
}
//获取信息
public function get_monster_info($id)
{
if (empty($id)) {
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
}
$monster_info = db::name('Monster')->where(['id' => $id])->find();
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_info];
}
//列表
public function get_monster_multiple_list($order, $sort, $page = 1, $limit = 20)
{
$list = db::name('monster_multiple')->order($order, $sort)->page($page, $limit)->select();
foreach ($list as $k => &$v) {
}
$data = [];
$data['count'] = db::name('monster_multiple')->count();
$data['list'] = $list;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//编辑
public function edit_monster_multiple($data)
{
if (empty($data)) {
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
}
$monster_info = db::name('monster_multiple')->find($data['id']);
if (empty($monster_info)) {
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
}
Db::startTrans();
try {
$update_data = [];
$update_data['multiple'] = $data['multiple'];
$update_data['updatetime'] = time();
$reslut = db::name('monster_multiple')->where(['id' => $data['id']])->update($update_data);
if (!$reslut) {
Db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
Db::commit();
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
} catch (\Exception $e) {
// 回滚事务
dump($e);
Db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
}
//获取信息
public function get_monster_multiple_info($id)
{
if (empty($id)) {
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
}
$monster_info = db::name('monster_multiple')->where(['id' => $id])->find();
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_info];
}
//列表
public function get_monster_log($order, $sort, $page = 1, $limit = 20)
{
$list = db::name('monster_log')->order($order, $sort)->page($page, $limit)->select();
foreach ($list as $k => &$v) {
$v['type_name'] = '暂未开奖';
$v['gid'] = 0;
$v['gift_name'] = '';
$v['base_image'] = '';
$v['gift_price'] = 0;
if($v['is_delete'] == 2){
$gift_info = db::name('Monster')->alias('a')->join('vs_gift b', 'a.gid = b.gid')->field('b.gid,b.gift_name,b.base_image,b.gift_price,a.type_name')->where('a.type', $v['win_type'])->find();
$v['gid'] = $gift_info['gid'];
$v['gift_name'] = $gift_info['gift_name'];
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
$v['gift_price'] = $gift_info['gift_price'];
$v['type_name'] = $gift_info['type_name'];
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
$v['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
}
}
$data = [];
$data['count'] = db::name('monster_log')->count();
$data['list'] = $list;
$totalRowData = db::name('monster_log')->field('count(1) as count,SUM(out_amount) as out_amount,SUM(in_amount) as in_amount')->find();
unset($totalRowData['count']);
$data['totalRow'] = $totalRowData;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//列表
public function get_user_monster_log($mid, $order, $sort, $page = 1, $limit = 20)
{
$list = db::name('user_monster_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
foreach ($list as $k => &$v) {
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
$v['nickname'] = $user_info['nickname'];
$v['avatar'] = localpath_to_netpath($user_info['avatar']);
$v['type_name'] = db::name('Monster')->where('type', $v['type'])->value('type_name');
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
}
$data = [];
$data['count'] = db::name('user_monster_log')->where('mid', $mid)->count();
$data['list'] = $list;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//列表
public function get_user_monster_win_log($mid, $order, $sort, $page = 1, $limit = 20)
{
$list = db::name('user_monster_win_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
foreach ($list as $k => &$v) {
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
$v['nickname'] = $user_info['nickname'];
$v['avatar'] = localpath_to_netpath($user_info['avatar']);
$v['type_name'] = db::name('Monster')->where('type', $v['win_type'])->value('type_name');
$gift_info = db::name('vs_gift')->where('gid', $v['win_gid'])->field('gid,gift_name,base_image,gift_price')->find();
$v['gift_name'] = $gift_info['gift_name'];
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
$v['gift_price'] = $gift_info['gift_price'];
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
}
$data = [];
$data['count'] = db::name('user_monster_win_log')->where('mid', $mid)->count();
$data['list'] = $list;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
}

View File

@@ -88,7 +88,8 @@ class Activities extends BaseCom
$uid = input('uid',$this->uid);
$permission_status = 1;
//查询是否首充
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
// $is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
$is_first_charge = db::name('user_coin_log')->where('user_id',$uid)->where('change_type',2)->count();
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
$system = request()->header('system');
$app_version = request()->header('App-Version');
@@ -313,7 +314,7 @@ class Activities extends BaseCom
$uid = input('uid',$this->uid);
$first_charge_permission = 1;
//查询是否首充
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
$is_first_charge = db::name('user_coin_log')->where('user_id',$uid)->where('change_type',2)->count();
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
if($is_first_charge > 0){
$first_charge_permission = 0;

View File

@@ -40,7 +40,7 @@ class BlindBoxTurntable extends BaseCom
$num = input('num',1);
$heart_id = input('heart_id',0);
$auction_id = input('auction_id',0);
if(!in_array($gift_bag_id,[10,11,12])){
if(!in_array($gift_bag_id,[10,11,12,61])){
return v(0,'非法活动ID', null);
}
//删除字符串里所有的空格
@@ -144,7 +144,8 @@ class BlindBoxTurntable extends BaseCom
* 1.开启 2.关闭
*/
public function blind_box_status(){
$reslut = model('BlindBoxTurntableGift')->blind_box_status();
$user_id = $this->uid;
$reslut = model('BlindBoxTurntableGift')->blind_box_status($user_id);
return v($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -15,6 +15,7 @@ class Cron
* 提现云账号订单状态查询
* 签约房时间结束处理
* 签约到期处理
* 酒吧房间麦位时间结束处理
*/
public function PerformPerSecond()
{
@@ -36,8 +37,6 @@ class Cron
//经业务调整 暂时不要了
//每10秒执行
public function TenSeconds()
{

View File

@@ -22,7 +22,8 @@ class Decorate extends BaseCom
public function get_type_list()
{
$have_hot = input('have_hot',0);
$reslut = model('Decorate')->get_type_list($have_hot);
$from = input('from',1);//来源1 道具商城 2 个性装扮
$reslut = model('Decorate')->get_type_list($have_hot,$from);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//获取装饰列表
@@ -80,7 +81,9 @@ class Decorate extends BaseCom
public function set_user_decorate(){
$uid = $this->uid;
$udid = input('udid', 0);
$reslut = model('Decorate')->set_user_decorate($uid,$udid);
$room_id = input('room_id', 0);
$num = input('num', 1);
$reslut = model('Decorate')->set_user_decorate($uid,$udid,$room_id,$num);
return v($reslut['code'], $reslut['msg'], $reslut['data']);
}
//取消装扮
@@ -91,4 +94,14 @@ class Decorate extends BaseCom
return v($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间热度卡使用
public function room_hot_card(){
$uid = $this->uid;
$udid = input('udid', 0);
$room_id = input('room_id', 0);
$num = input('num', 1);
$reslut = model('Decorate')->room_hot_card($uid,$udid,$room_id,$num);
return v($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -19,7 +19,8 @@ class Gift extends BaseCom
{
$no_label = input('no_label','');
$no_label = explode(',',$no_label);
$reslut = model('Gift')->get_gift_label($no_label);
$type = input('type',1);
$reslut = model('Gift')->get_gift_label($type,$no_label);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}

View File

@@ -0,0 +1,109 @@
<?php
namespace app\api\controller;
use app\common\controller\BaseCom;
use think\Controller;
use think\Db;
/**
* 活动:
* 1.首充好礼
*
*/
class Monster extends BaseCom
{
//初始化
protected function initialize()
{
//允许跨域
header('Access-Control-Allow-Origin: *');
}
//选择金币列表
public function choice_gold_list(){
$reslut = model('Monster')->choice_gold_list();
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//游戏详情
public function get_monster_info(){
$uid = $this->uid;
$reslut = model('Monster')->get_monster_info($uid);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//生成/结算喂养怪兽
public function create_monster_log(){
$uid = $this->uid;
$key_name = "api:Monster:create_monster_log";
redis_lock_exit($key_name);
$reslut = model('Monster')->create_monster_log();
redis_unlock($key_name);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//喂养怪兽
public function open_beat_monster(){
$uid = $this->uid;
$rid = input('rid', 0);
$type = input('type', 0);
$num = input('num', 0);
$key_name = "api:Monster:open_beat_monster:uid:".$uid;
redis_lock_exit($key_name);
$reslut = model('Monster')->open_beat_monster($uid, $rid, $type, $num);
redis_unlock($key_name);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//规则
public function get_monster_note(){
$reslut = model('Monster')->get_monster_note();
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//奖池
public function get_monster_box_list(){
$reslut = model('Monster')->get_monster_box_list();
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//开奖记录
public function get_monster_log(){
$uid = $this->uid;
$page = input('page', 1);
$page_limit = input('page_limit', 20);
$reslut = model('Monster')->get_monster_log($uid, $page, $page_limit);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//我的记录
public function get_user_monster_log(){
$uid = $this->uid;
$page = input('page', 1);
$page_limit = input('page_limit', 20);
$reslut = model('Monster')->get_user_monster_log($uid, $page, $page_limit);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//中奖次数榜单
public function get_monster_winner_num_list(){
$uid = $this->uid;
$time = input('time', 1);
$reslut = model('Monster')->get_monster_winner_num_list($uid, $time);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
//设置房间期数开关
public function operate_room_monster_show_status(){
$uid = $this->uid;
$rid = input('rid', 0);
$is_show_monster_push = input('is_show_monster_push', 1);
$reslut = model('Monster')->operate_room_monster_show_status($uid, $rid, $is_show_monster_push);
return V($reslut['code'],$reslut['msg'], $reslut['data']);
}
}

View File

@@ -39,7 +39,7 @@ class Nobility extends BaseCom
public function buy_nobility(){
$lid = input('lid', 0);
$uid = input('uid', $this->uid);
$reslut = model('Nobility')->buyNobility($uid,$lid);
$reslut = model('Nobility')->buyNobility($uid,$lid,$is_send);
return V($reslut['code'],$reslut['msg'], null);
}
}

View File

@@ -22,7 +22,7 @@ class Payment extends Controller
* APP支付
*/
public function app_pay() {
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信 6-苹果支付
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信 6-苹果支付 7-JSAPI支付
$user_id = input('user_id', 0);
$money = input('money', 0);
$coin = input('coin', 0);
@@ -430,4 +430,60 @@ class Payment extends Controller
return false;
}
//微信JSAPI支付
public function pay_jsapi(){
$user_code = input('user_code');
$money = input('money', 0);
$coin = $money * get_system_config_value('rmb_coin_ratio');
if (!$user_code) {
return V(0, '请选择充值用户', null);
}
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money > 5000) {
return V(0, '请选择正确的充值金额', null);
}
$user_id = db::name('user')->where(["user_code" => $user_code])->value('id');
//获取用户的手机号
$user_phone = db::name('user')->where(["id" => $user_id])->value('mobile');
if(!$user_phone){
return V(0, '请先绑定手机号!', null);
}
//获取用户的实名信息
$real_name = db::name('user_auth')->where(["mobile" => $user_phone,'is_real' => 1])->find();
if(!$real_name){
return V(0, '请先实名认证', null);
}
//获取用户的年龄
if(!getAgeId($real_name['card_id'])){
return V(0, '未成年不可充值!', null);
}
$title = '充值到app用户'. $user_code ."余额!";
$order_number = $this->createOrderSn();
$data['order_sn'] = $order_number;
$data['money'] = $money;
$data['user_id'] = $user_id;
$data['pay_type'] = 7; //JSAPI支付
$data['coin'] = $coin;
$data['createtime'] = time();
$data['remarke'] = $title;
$re = db::name('vs_user_recharge')->insert($data);
if (!$re) {
return V(0, '充值失败', null);
}
//引用微信sdk
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
$wx = new \WxPay();
$result = $wx->WxPayJsapi($data);
return V(1, 'app支付', $result);
}
}

View File

@@ -15,6 +15,7 @@ class Room extends BaseCom
$room_name = input('room_name', '');
$room_cover = input('room_cover', '');
$room_intro = input('room_intro', '');
$password = input('room_password');
$signCount = db::name('vs_user_sign')->where(['parent_user_id' => $this->uid ,'end_time' => ['>', time()]] )->count();
$num = get_system_config_value('sign_num_per_room');
@@ -25,7 +26,7 @@ class Room extends BaseCom
$key_name = "api:room:user_create_room:" . $this->uid;
redis_lock_exits($key_name);
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0);
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0,$password);
redis_unlock($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
@@ -39,8 +40,12 @@ class Room extends BaseCom
$room_cover = input('room_cover', '');
$room_intro = input('room_intro', '');
$room_background_id = input('room_background', '');
$password = input('room_password');
if($room_id <= 0){
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
}
$reslut = model('Room')->user_edit_room($this->uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id);
$reslut = model('Room')->user_edit_room($this->uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id,$password);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
@@ -136,7 +141,10 @@ class Room extends BaseCom
public function join_room()
{
$room_id = input('room_id', 0);
$password = input('password', '');
if($room_id == 0){
return V(0, '房间不存在');
}
$password = input('room_password');
//检测系统是否维护中
$is_maintenance = get_system_config_value('is_maintenance');
@@ -186,30 +194,6 @@ class Room extends BaseCom
}
//直播间送礼【1.6废弃】
//
public function room_give_gift()
{
$key_name = "api:room:gift:" . $this->uid;
redis_lock_exit($key_name);
$room_id = input('room_id', 0);
$gift_id = input('gift_id', 0);
$gift_num = input('gift_num', 1);
$to_uid = input('to_uid', 0);//收礼人ID逗号隔开的字符串
$type = input('type', 1);//1金币购买 2送背包礼物
$pit_number = input('pit_number', 0);
$heart_id = input('heart_id', 0);
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
if($gift_id == $pool_gift_id){
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
}else{
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number,$heart_id);
}
redis_unlock($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间送礼 背包一键全清
public function room_gift_all_clear()
{
@@ -273,6 +257,8 @@ class Room extends BaseCom
$reslut = model('HeadLine')->current_headline();
return V(1, '成功', $reslut);
}
//发(抢)头条
public function send_headline()
{
@@ -323,11 +309,77 @@ class Room extends BaseCom
}
//房间类型列表
public function room_type_list()
{
$http = get_system_config_value("web_site");
//1-交友,2-拍卖7-互娱8-交友不要了9-点唱10-签约11-酒吧房
$reslut = [
[
'id' => 1,
'name' => '交友',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 1,
],
[
'id' => 2,
'name' => '拍卖',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 2,
],
[
'id' => 7,
'name' => '互娱',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 3,
],
[
'id' => 9,
'name' => '点唱',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 4,
],
[
'id' => 10,
'name' => '签约',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 5,
],
[
'id' => 11,
'name' => '酒吧',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 6,
],
[
'id' => 99,
'name' => '练歌',
'icon' => $http.'/data/avatar/head_pic.png',
'sort' => 7,
],
];
//根据sort 排序
usort($reslut, function ($a, $b) {
return $a['sort'] - $b['sort'];
});
return V(1, '成功', $reslut);
}
//修改房间类型
public function change_room_type()
{
$room_id = input('room_id', 0);
$type = input('type', 1);//1-交友,2-拍卖7-互娱,8-交友(不要了),9-点唱10-签约11-酒吧房
$type = input('type', 1);//1-交友,2-拍卖7-互娱9-点唱10-签约11-酒吧房99-练歌
if(!$room_id || !$type){
return V(0, '参数错误');
}
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $this->uid])->field('id')->find();
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'delete_time' => null])->find();
if(!$owner && !$host){
return V(0, '没有权限操作');
}
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
@@ -501,4 +553,18 @@ class Room extends BaseCom
$reslut = model('Room')->set_room_business_time($this->uid, $room_id, $start_time, $end_time);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//设置房间密码【改到编辑房间】暂时不用了
public function set_room_password()
{
$room_id = input('room_id', 0);
$password = input('password', '');
if(!$room_id){
return V(0, '参数错误');
}
$reslut = model('Room')->set_room_password($this->uid, $room_id, $password);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -31,9 +31,12 @@ class SendGift extends BaseCom
}
//获取幸运币
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
if($gift_id == $pool_gift_id){//送的是幸运币
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
$pool_gift_ids = Db::name('bb_lottery_config')->column('value', 'key');
//转成数组
$pool_gift_id_arr = [$pool_gift_ids['pool_gift_id']??0,$pool_gift_ids['pool_gift_id_5']??0,$pool_gift_ids['pool_gift_id_10']??0];
if(in_array($gift_id, $pool_gift_id_arr)){//送的是幸运币
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num,$pool_gift_ids);
redis_unlocks($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}else{

View File

@@ -82,6 +82,16 @@ class User extends BaseCom
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//礼物墙礼物用户列表
public function gift_wall_user_list()
{
$uid = input('user_id', 0);
$gift_id = input('gift_id', 0);
$reslut = model('User')->gift_wall_user_list($uid,$gift_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//相册列表
public function get_album_list()
{

View File

@@ -0,0 +1,103 @@
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Log;
class Wechat extends Controller
{
private string $appId = 'wx0f0c0c0c0c0c0c0c';
private string $appSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
/*
* 核心用code换取openid的方法
* @param string $code 微信回调带来的code
* @return string|bool 成功返回openid失败返回false
*/
public function exchangeOpenId()
{
$code = input('code', 0);
// 构建请求URL
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?" .
"appid={$this->appId}&" .
"secret={$this->appSecret}&" .
"code={$code}&" .
"grant_type=authorization_code";
Log::info('[微信授权] 请求微信接口URL' . $url);
// 发送请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
Log::error('[微信授权] 请求失败:' . curl_error($ch));
curl_close($ch);
return V(0, '[微信授权] 请求失败:' . curl_error($ch));
}
curl_close($ch);
Log::info('[微信授权] 微信返回原始数据:' . $response);
// 解析返回的JSON
$data = json_decode($response, true);
if (empty($data) || isset($data['errcode'])) {
Log::error('[微信授权] 解析失败或返回错误'.json_encode($data));
return V(0, '[微信授权] 解析失败或返回错误');
}
// 成功获取到openid
return V(1, '获取成功', $data['openid']);
}
/*
* 获取用户信息
* @param string $user_code 用户的user_code
* @return array|bool 成功返回用户信息失败返回false
*/
public function getUserInfo()
{
$user_code = input('user_code', 0);
$user_info = db::name('user')
->field('id user_id,nickname,avatar,mobile,user_code')
->where(['user_code' => $user_code,'status' => ['<>',0]])->find();
if(!$user_info){
return ['code' => 0, 'msg' => '用户不存在或已注销', 'data' => null];
}
return V(1, '获取成功', $user_info);
}
/*
* 可充值的金额
* @param string $user_code 用户的user_code
* @return array|bool 充值金额失败返回false
*/
public function getRechargeMoney()
{
$money_coin = [
['coin' => '1', 'money' => '0.10'],
['coin' => '60', 'money' => '6.00'],
['coin' => '1000', 'money' => '100.00'],
];
return V(1, '获取成功', $money_coin);
}
}

View File

@@ -30,12 +30,16 @@ class Xintiao extends BaseCom
'updatetime' => time()
]);
}
//任务18-每日在线时长 5 分钟
model('Tasks')->tasks_complete($user_id,18);
//任务19-每日在线时长 10 分钟
model('Tasks')->tasks_complete($user_id,19);
//任务20-每日在线时长 15 分钟
model('Tasks')->tasks_complete($user_id,20);
//查询房间是否热门房间
$is_hot_room = db::name('vs_room')->where(['id' => $room_id,'is_hot' => 2])->find();
if($is_hot_room){
//任务18-每日在线时长 5 分钟
model('Tasks')->tasks_complete($user_id,18);
//任务19-每日在线时长 10 分钟
model('Tasks')->tasks_complete($user_id,19);
//任务20-每日在线时长 15 分钟
model('Tasks')->tasks_complete($user_id,20);
}
//获取房间的类型
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');

View File

@@ -23,18 +23,18 @@ class BlindBoxTurntableGift extends Model
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();
$gifts = db::name('vs_gift_bag_detail')->alias('a')
->field('a.*,aa.gid,aa.gift_name,aa.base_image,aa.play_image,aa.gift_price')
->join('vs_gift aa','a.foreign_id = aa.gid')
->where('gift_bag_id',$gift_bag_id)->order("gift_price 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'];
}
$gift_list[$key]['number'] = $key;
$gift_list[$key]['gift_id'] = $value['gid'];
$gift_list[$key]['gift_name'] = $value['gift_name'];
$gift_list[$key]['base_image'] = $value['base_image'];
$gift_list[$key]['play_image'] = $value['play_image'];
$gift_list[$key]['gift_price'] = $value['gift_price'];
}
$ext = json_decode($box['ext'],true);
$box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find();
@@ -464,10 +464,32 @@ class BlindBoxTurntableGift extends Model
}
//盲盒转盘开启状态
public function blind_box_status(){
$gift_bag_ids = [11,12];
public function blind_box_status($user_id=0){
$gift_bag_ids = [11,12,60,61];
$gift_bag = db::name('vs_gift_bag')->where(['id'=>['in',$gift_bag_ids]])->select();
$open_monster_status = get_system_config_value('open_monster_status');
$fun_activities_recharge_restrictions = get_system_config_value('fun_activities_recharge_restrictions');
if($fun_activities_recharge_restrictions ==0){
return ['code' => 0, 'msg' => '趣味活动关闭', 'data' => null];
}
//用户充值金额
$user_recharge_money = db::name('vs_user_recharge')->where(['user_id'=>$user_id,'pay_status'=>2])->sum('money');
//内测用户
//先从cache中获取
$inside_uid = Cache::get('inside_uid');
if(!$inside_uid){
$inside_uid = get_system_config_value('inside_uid');
//缓存 并设置缓存时间
Cache::set('inside_uid',$inside_uid,3600);
}
$inside_uid = explode(',',$inside_uid);
if(($user_recharge_money < $fun_activities_recharge_restrictions) && !in_array($user_id,$inside_uid)){
return ['code' => 0, 'msg' => '充值金额不足', 'data' => null];
}
foreach ($gift_bag as $bag){
if($bag['id']==60 && $open_monster_status ==0){
$bag['status'] = 0;
}
if($bag['status'] == 1){
$result_data[] = [
'gift_bag_id' => $bag['id'],

View File

@@ -38,6 +38,10 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
public function draw_gift(int $gift_bag_id, int $user_id, string $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0, $auction_id = 0)
{
try {
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
if($bag_data['status']==0){ //其他转盘游戏
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
}
// 收礼人
$gift_user_ids = explode(',', $gift_user_ids);
$total_num = $num * count($gift_user_ids); //总数量
@@ -682,6 +686,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
if($type=="set"){
$xlh_periods_num = $periods;
Cache::set($cacheKey, $xlh_periods_num, 0);
}else{
if(empty($xlh_periods_num)){
$xlh_periods_num = Db::name("vs_room_pan_xlh")
->order('id desc')
->value('periods');
Cache::set($cacheKey, $xlh_periods_num, 0);
}
}
return $xlh_periods_num;
}
@@ -1067,9 +1078,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
{
$resultList = [];
foreach ($giftCounts as $gift) {
$gift_data = Db::name('vs_gift')->where(['gid'=>$gift['gift_id']])->find();
$resultList[] = [
'gift_id' => $gift['gift_id'],
'count' => $gift['count']
'count' => $gift['count'],
'gift_price' => $gift_data['gift_price'],
'gift_name' => $gift_data['gift_name'],
'base_image' => $gift_data['base_image'],
];
}
return [
@@ -1098,6 +1113,10 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
return ['code' => 0, 'msg' => '用户不在房间,无法获取房主信息', 'data' => null];
}
$gift_bag_id = 13;
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
if($bag_data['status']==0){ //其他转盘游戏
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
}
// 1. 获取并缓存盲盒配置
$ext = $this->getCachedGiftBag($gift_bag_id); //获取转盘信息
$bag_gift_price = $ext['xlh_box_price'] * $num;
@@ -1529,6 +1548,18 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
public function draw_gift_drop_bag($gift_bag_id, $user_id, $num = 1, $room_id = 0)
{
try {
$open_monster_status = get_system_config_value('open_monster_status');
$fun_activities_recharge_restrictions = get_system_config_value('fun_activities_recharge_restrictions');
if($fun_activities_recharge_restrictions == 0){
return ['code' => 0, 'msg' => '趣味活动关闭', 'data' => null];
}
if($gift_bag_id ==60 && $open_monster_status ==0){ //恋仙传说
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
}
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
if(in_array($gift_bag_id,[11,12,61]) && $bag_data['status']==0){ //其他转盘游戏
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
}
// 参数验证
$validation_result = $this->validateDrawParams($gift_bag_id, $user_id, $num);
if ($validation_result['code'] !== 1) {

View File

@@ -18,8 +18,10 @@ class Decorate extends Model
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮'];
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮',13=>"房间热度卡"];
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼',9=>'爵位购买赠送',10=>'任务奖励',11=>"每日签到"];
//特殊装扮(卡片类型 可直接购买 不用配置天数价格)
public $SpecialType = [12=>'降身卡',13=>'房间热度卡'];
public function __construct($data = [])
{
parent::__construct($data);
@@ -27,7 +29,7 @@ class Decorate extends Model
}
//获取装扮类型
public function get_type_list($have_hot = 0)
public function get_type_list($have_hot = 0,$from=1)
{
$no_show_ids = [7,8,3,10,11];
$label = $this->TypeArray;
@@ -40,6 +42,11 @@ class Decorate extends Model
if (in_array($k, $no_show_ids)) {
continue;
}
if($from==2){
if($k==13){
continue;
}
}
$data[$i]['id'] = $k;
$data[$i]['name'] = $v;
++$i;
@@ -77,9 +84,9 @@ class Decorate extends Model
'a.type' => $type,
];
}
if($type == 12){
if(in_array($type, array_keys($this->SpecialType))){
$map = [
'type' => 12,
'type' => $type,
'delete_time' => 0,
'show_status' => 1,
'is_buy' => 1
@@ -114,7 +121,7 @@ class Decorate extends Model
if (!$decorate) {
return ['code' => 0, 'msg' => '参数错误'];
}
if($decorate['type'] == 12){
if(in_array($decorate['type'], array_keys($this->SpecialType))){
$result['title'] = $decorate['title'];
$result['price'] = (int)$decorate['price'];
$result['base_image'] = localpath_to_netpath($decorate['base_image']);
@@ -149,7 +156,7 @@ class Decorate extends Model
*
*/
public function pay_decorate($uid, $did, $day=0,$from_type=1,$give_uid=0,$log_remark="",$num=1){
if(empty($day) && $from_type == 12){
if(empty($day) && in_array($from_type,array_keys($this->SpecialType))){
$day = 0;
}else{
$day = db::name('vs_decorate_price')->where(['did'=>$did])->order('day asc')->value('day');
@@ -171,7 +178,7 @@ class Decorate extends Model
if(!$decorate_info){
return ['code' => 0, 'msg' => '该装扮不存在'.$did, 'data' => null];
}
if($decorate_info['type'] != 12){
if(!in_array($decorate_info['type'],array_keys($this->SpecialType))){
//该天数是否存在
$map = [];
$map = [
@@ -251,7 +258,7 @@ class Decorate extends Model
$data['num'] = 1;
$result = db::name('vs_user_decorate')->insert($data);
}else{
if($decorate_info['type'] == 12){
if(in_array($decorate_info['type'],array_keys($this->SpecialType))){
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update([
'is_using' => 2,
'num' => $user_decorate_data['num'] + $num,
@@ -290,7 +297,7 @@ class Decorate extends Model
if($decorate_price_info['day'] ==0){
$insert_data['end_time'] = 0; //永久礼物
}
$insert_data['day_num'] = $day;
$insert_data['day_num'] = $day??0;
$insert_data['pay_price'] = $pay_price ;
$insert_data['special_num'] = $decorate_info['special_num'];
$insert_data['give_uid'] = $give_uid;
@@ -315,10 +322,10 @@ class Decorate extends Model
//用户装扮列表
public function user_decorate($uid, $type,$page=1, $limit=10){
if($type == 12){
if(in_array($type, array_keys($this->SpecialType))){
$reslut = db::name('vs_user_decorate')
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value')
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value,d.price')
->where('ud.user_id', $uid)
->where('ud.type', $type)
->where(['ud.num'=>[">",0]])
@@ -327,7 +334,7 @@ class Decorate extends Model
}else{
$reslut = db::name('vs_user_decorate')
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type')
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,d.price')
->where('ud.user_id', $uid)
->where('ud.type', $type)
->where(['ud.end_time'=>[">=",time()]])
@@ -347,7 +354,7 @@ class Decorate extends Model
}
// 设置用户装修
public function set_user_decorate($uid,$udid)
public function set_user_decorate($uid,$udid,$room_id,$num=1)
{
$map = [];
$map = [
@@ -358,7 +365,7 @@ class Decorate extends Model
if (empty($info)) {
return ['code' => 0, 'msg' => '装扮不存在', 'data' => null];
}
if($info['type'] == 12){
if(in_array($info['type'],array_keys($this->SpecialType))){
if ($info['num']-1 < 0) {
return ['code' => 0, 'msg' => '无可用装扮', 'data' => null];
}
@@ -391,8 +398,8 @@ class Decorate extends Model
$data = [];
$data['is_using'] = 1;
$data['updatetime'] = time();
if($info['type'] == 12){
$data['num'] = $info['num'] - 1;
if(in_array($info['type'],array_keys($this->SpecialType))){
$data['num'] = $info['num'] - $num;
}
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
if (!$reslut) {
@@ -426,7 +433,37 @@ class Decorate extends Model
'createtime'=> time()
]);
}
}else{
}elseif($info['type'] == 13){//房间热度卡 增加房间热度
if (empty($room_id)) {
Db::rollback();
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
}
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
if (empty($room_info)) {
Db::rollback();
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
}
$increase_hot_value_all = 0;
for ($i = 0; $i < $num; $i++) {
$increase_hot_value = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
if ($room_info['today_hot_value'] <= $increase_hot_value) {
db::name('vs_room')->where(['id' => $room_id])->update(['today_hot_value' => 0]);
} else {
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value);
}
$increase_hot_value_all += $increase_hot_value;
}
//记录日志
db::name('vs_room_hot_up_log')->insert([
'did' => $udid,
'user_id' => $uid,
'room_id' => $room_id,
'hot_value' => $increase_hot_value_all,
'before_hot_value' => $room_info['today_hot_value'],
'end_time' => date('Y-m-d H:00:00', time()),
'createtime' => time()
]);
} else{
//推送信息去所在房间
//查询当前所在房间
$room_id = db::name('vs_room_visitor')->where(['user_id' => $uid])->order('id' , 'desc')->value('room_id');
@@ -545,4 +582,159 @@ class Decorate extends Model
}
return $reslut;
}
//房间热度卡使用
public function room_hot_card($uid,$udid,$room_id,$num=1)
{
$map = [];
if($udid){
$map = [
'user_id' => $uid,
'udid' => $udid
];
$info = db::name('vs_user_decorate')->where($map)->find();
if (empty($info)) {
return ['code' => 0, 'msg' => '房间热度卡不存在', 'data' => null];
}
if ($info['num']-$num < 0) {
return ['code' => 0, 'msg' => '无可用房间热度卡', 'data' => null];
}
}else{
$map = [
'user_id' => $uid,
'type' => 13,
'num' => ['>',0]
];
$info = db::name('vs_user_decorate')->where($map)->select();
}
Db::startTrans();
try {
if($udid){
$map = [
'user_id' => $uid,
'udid' => $udid
];
$data = [];
$data['is_using'] = 1;
$data['updatetime'] = time();
$data['num'] = $info['num'] - $num;
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
if (!$reslut) {
Db::rollback();
return ['code' => 0, 'msg' => "使用失败", 'data' => null];
}
if (empty($room_id)) {
Db::rollback();
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
}
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
if (empty($room_info)) {
Db::rollback();
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
}
$increase_hot_value = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
$increase_hot_value = $increase_hot_value * $num;
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value);
//记录日志
db::name('vs_room_hot_up_log')->insert([
'did' => $info['did'],
'user_id' => $uid,
'room_id' => $room_id,
'hot_value' => $increase_hot_value,
'before_hot_value' => $room_info['today_hot_value'],
'end_time' => date('Y-m-d H:00:00', time()),
'createtime' => time()
]);
//推送消息
$FromUserInfo = db::name('user')->where(['id' => $uid])->find();
$text1 = $FromUserInfo['nickname'] . ' 在本房间使用了房间热度卡 提升房间'.$increase_hot_value.'热度';
$text = [
'FromUserInfo' => $FromUserInfo,
'ToUserInfo' => null,
'GiftInfo' => [
'gift_id' => 0,
'gift_name' => '房间热度卡',
'gift_icon' => "",
'play_image' => "",
'base_image' => db::name('vs_decorate')->where(['did' => $info['did']])->value('base_image'),
],
'gift_num' => $num,
'text' => $text1
];
//聊天室推送系统消息
model('Chat')->sendMsg(1005,$room_id,$text);
}else{
$map = [
'user_id' => $uid,
'type' => 13,
'num' => ['>',0]
];
$data = [];
$data['is_using'] = 1;
$data['updatetime'] = time();
$data['num'] = 0;
$result = Db::name('vs_user_decorate')->where($map)->update($data);
if (!$result) {
Db::rollback();
return ['code' => 0, 'msg' => "使用失败", 'data' => null];
}
if (empty($room_id)) {
Db::rollback();
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
}
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
if (empty($room_info)) {
Db::rollback();
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
}
$increase_hot_value_all = 0;
foreach ($info as $key => $value) {
$increase_hot_value = db::name('vs_decorate')->where(['did' => $value['did']])->value('ext_value') ?? 0;
$increase_hot_value = $increase_hot_value * $value['num'];
$increase_hot_value_all += $increase_hot_value;
}
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value_all);
//记录日志
db::name('vs_room_hot_up_log')->insert([
'did' => 0,
'user_id' => $uid,
'room_id' => $room_id,
'hot_value' => $increase_hot_value_all,
'before_hot_value' => $room_info['today_hot_value'],
'end_time' => date('Y-m-d H:00:00', time()),
'createtime' => time()
]);
//推送消息
$FromUserInfo = db::name('user')->where(['id' => $uid])->find();
$text1 = $FromUserInfo['nickname'] . ' 在本房间使用了房间热度卡 提升房间'.$increase_hot_value_all.'热度';
$text = [
'FromUserInfo' => $FromUserInfo,
'ToUserInfo' => null,
'GiftInfo' => [
'gift_id' => 0,
'gift_name' => '房间热度卡',
'gift_icon' => "",
'play_image' => "",
'base_image' => db::name('vs_decorate')->where(['did' => $info['did']])->value('base_image'),
],
'gift_num' => $num,
'text' => $text1
];
//聊天室推送系统消息
model('Chat')->sendMsg(1005,$room_id,$text);
}
// 提交事务
Db::commit();
//更新装备缓存
$cache_key = 'user_base_info_'.$uid;
Cache::rm($cache_key);
return ['code' => 1, 'msg' => "设置成功", 'data' => null];
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return ['code' => 0, 'msg' => "设置失败", 'data' => null];
}
}
}

View File

@@ -18,9 +18,13 @@ class Gift extends Model
protected $table = 'fa_vs_gift';
//获取礼物类型
public function get_gift_label($no_label = [])
public function get_gift_label($type,$no_label = [])
{
if($type == 2) {//打赏 不需要热度卡
$no_label = [1013,2];
}
$giftType = [];
//礼物
$giftTypeData = db::name('vs_gift_label')
->where('delete_time',0)
->where('tid',1)
@@ -30,13 +34,51 @@ class Gift extends Model
foreach ($giftTypeData as $key => $value) {
$giftType[$key]['id'] = $value['id'];
$giftType[$key]['name'] = $value['name'];
$giftType[$key]['sort'] = $value['sort'];
}
//增加房间热度卡
if (!in_array(1013, $no_label)) {
$giftType[] = ['id' => 1013, 'name' => '房间热度卡', 'sort' => 0];
}
//排序 1013排到最前面去
usort($giftType, function($a, $b) {
return $a['sort'] <=> $b['sort'];
});
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
}
//拉取礼物列表
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
{
if($label == 1013){//房间热度卡
$list = db::name('vs_user_decorate')
->field('a.udid,a.num,b.title,b.base_image,b.price,b.ext_value')
->alias('a')
->join('vs_decorate b','a.did=b.did')
->where([
'a.user_id'=>$user_id,
'a.type'=>13,
'a.num' => ['>',0]
])
->order('a.num desc')
->select();
$return_data = [];
if($list){
foreach ($list as $k=>$v) {
$return_data[$k]['gift_id'] = $v['udid'];
$return_data[$k]['gift_name'] = $v['title'];
$return_data[$k]['base_image'] = $v['base_image'];
$return_data[$k]['gift_price'] = $v['price'];
$return_data[$k]['num'] = $v['num'];
$return_data[$k]['label'] = 1013;
}
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
}
//其他礼物类型
$is_lock = 0;
if ($label == 13) { // 专属礼物
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
@@ -60,19 +102,21 @@ class Gift extends Model
$map['delete_time'] = 0;
$where['is_show'] = 1;
if ($label && $label != 99) {
$map['label'] = $label;
}
if ($label == 99) {
if ($label == 99) { // 拍卖卡关系选择的礼物
$gift_price = get_system_config_value('room_love_auction_cion');
$where['gift_price'] = ['>',$gift_price];
$where['label'] = ['<>',2];
$where['label'] = ['in',[1,5]];
}elseif ($label == 100) {// 哥单礼物
$gift_price = get_system_config_value('singer_lowest_cion');//歌单最低价格
$where['gift_price'] = ['>',$gift_price];
$where['label'] = ['in',[1,5]];
}elseif($label == 0){// 其他普通礼物
$where['label'] = ['in',[1,5]];
}else{
$map['label'] = $label;
}
$is_open_blind_box_turntable = 1;
// if($room_id){
// $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable');
// }
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort desc, gift_price asc')->select();
if($label==2){
$list_data = [];
@@ -91,8 +135,11 @@ class Gift extends Model
}
}
//爆币
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
if($pool_gift_id == $v['gift_id']){
$pool_gift_id_arr[] = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
$pool_gift_id_arr[] = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id_5'])->value('value');
$pool_gift_id_arr[] = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id_10'])->value('value');
if(in_array($v['gift_id'],$pool_gift_id_arr)){
$v['gift_bag_name'] = "幸运币活动";
$v['rule'] = "幸运羽币";
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=35";

View File

@@ -281,8 +281,6 @@ class GiveGift extends Model
model('Chat')->sendMsg(1015,$roomPKinfo['room_id_b'],$text);
}
}
//直播间送礼物 每日任务
model('DailyTasks')->tasks_complete($uid,3);
}
//cp检测
model('api/UserCp')->checkGift($uid, $gid, $to_id, $from_id,$num,$gift_price);
@@ -421,19 +419,47 @@ class GiveGift extends Model
//使用收礼用户 和礼物ID 查询礼物墙
$gift_wall = db::name('user_gift_wall')->where(['user_id'=>$to_id,'gift_id'=>$gid])->find();
if($gift_wall){
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])->inc('count',$num)->update();
$userIds = explode(',',$gift_wall['give_user_ids']);
if(!in_array($uid,$userIds)){
$userIds[] = $uid;
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])->update(['give_user_ids'=>implode(',',$userIds)]);
if($gift_wall){//更新
//往期送礼用户
$users = json_decode($gift_wall['give_user_ids'], true);
if($users){
$ture = false;
foreach ($users as $user_id){
if($user_id['user_id'] == $uid){
$user_id['count'] += $num;
$ture = true;
}
}
if(!$ture){
$users[] = [
'user_id' => $uid,
'count' => $num
];
}
$users_list = json_encode($users);
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])
->update(['give_user_ids'=>$users_list,'updatetime' => time(),'count' => $gift_wall['count'] + $num]);
}else{
$users[] = [
'user_id' => $uid,
'count' => $num
];
$users_list = json_encode($users);
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])
->update(['give_user_ids'=>$users_list,'updatetime' => time(),'count' => $num]);
}
}else{
}else{//新增
$users[] = [
'user_id' => $uid,
'count' => $num
];
$users_list = json_encode($users);
db::name('user_gift_wall')->insert([
'user_id' => $to_id,
'gift_id' => $gid,
'count' => $num,
'give_user_ids' => $uid,
'give_user_ids' => $users_list,
'updatetime' => time()
]);
}
@@ -979,10 +1005,10 @@ class GiveGift extends Model
'createtime' => time()
];
$res = Db::name('vs_user_money_log')->insert($data);
if(!$res){
// $res = Db::name('vs_user_money_log')->insert($data);
// if(!$res){
return false;
}
// }
//根据类型判断是操作金币还是钻石得增加或减少
if($money_type == 1){//1金币

View File

@@ -275,6 +275,10 @@ class Guild extends Model
$update_data['is_show_room'] = 1;
$update_data['apply_time'] = time();
$update_data['remarks'] = $remarks;
$room_info = db::name('vs_room')->where(['user_id'=>$is_operate['user_id'],'delete_time'=>0,'type_id'=>['<>',6]])->find();
if($room_info){
$update_data['room_id'] = $room_info['id'];
}
//结算比例
$configs = get_system_config();
//未加入工会的收益
@@ -364,6 +368,11 @@ class Guild extends Model
if($reslut){
//减少公会人数
db::name('vs_guild')->where('id', $guild_info['id'])->setDec('num');
if($guild_id<=95){ //事故处理-114以前的群被删了
$guild_id = "g".$guild_id;
}else{
$guild_id = $guild_id;
}
model('api/Tencent')->delete_group_member('g'.$guild_id, $user_id);
return ['code' => 1, 'msg' => '踢出成功','data' => null];
}else{
@@ -770,9 +779,9 @@ class Guild extends Model
continue;
}
$consumption = db::name('vs_user_money_log')
$consumption = db::name('user_coin_log')
->whereIn('change_type',$coin_consumption_type_array)
->where(['money_type'=>1,'user_id' => $value['user_id']])
->where(['user_id' => $value['user_id']])
->where('createtime', '>=', $actual_start_time)
->where('createtime', '<=', $actual_end_time)
->sum('change_value');
@@ -792,7 +801,7 @@ class Guild extends Model
$list = Db::name('vs_guild_user')
->alias('a')
->join('user b', 'a.user_id = b.id')
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
->join('user_coin_log c', 'a.user_id = c.user_id AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
->group('a.user_id')
@@ -803,7 +812,7 @@ class Guild extends Model
$count = Db::name('vs_guild_user')
->alias('a')
->join('user b', 'a.user_id = b.id')
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
->join('user_coin_log c', 'a.user_id = c.user_id AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
->group('a.user_id')
@@ -1138,12 +1147,17 @@ class Guild extends Model
* 设置群聊信息
*/
public function set_guild_info($guild_id,$name,$notice,$avatar){
if($guild_id<=95){
$guild_id = "g".$guild_id;
}else{
$guild_id = $guild_id;
}
$guild_id = 'g'.$guild_id;
$return = model('api/Tencent')->modify_group_base_info($guild_id, $name,$avatar, $notice);
return ['code' => $return['code'], 'msg' => $return['msg'], 'data' => $return['data']];
}
/*
/*dd
* 我的公会
* @param $id
* @param $user_id

View File

@@ -4,6 +4,8 @@ namespace app\api\model;
use app\common\controller\Push;
use app\common\service\LotteryService;
use app\common\service\LotteryService5;
use app\common\service\LotteryService10;
use think\Db;
use think\Exception;
use think\Log;
@@ -15,7 +17,7 @@ class Lottery extends Model
* 送礼参与抽奖接口
* @return json
*/
public function gift($send_uid, $recv_uid,$gift_id, $room_id, $num)
public function gift($send_uid, $recv_uid, $gift_id, $room_id, $num, $pool_gift_ids)
{
if (ceil($num) != $num) {
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
@@ -47,7 +49,6 @@ class Lottery extends Model
//送礼 开启事务
Db::startTrans();
//扣除用户金币并记录日志
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$all_gift_price,$room_id,1,10,'用户金币购买幸运币礼物');
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid, $all_gift_price, $room_id, 10, '用户金币购买幸运币礼物');
if(!$wallet_update){
Db::rollback();
@@ -62,6 +63,21 @@ class Lottery extends Model
//送给一人礼物的总价格(扣除用户的数额)
$gift_price = $gift_info['gift_price'] * $num;
//幸运币收益率
$lucky_rate = db::name('bb_lottery_config')->where(['key' => 'lucky_rate'])->value('value');
$recv_coin = round($gift_price * $lucky_rate / 100, 2);
$small_pool = $gift_price - $recv_coin;
if($gift_id == $pool_gift_ids['pool_gift_id_5']){
$table = 'bb_lottery_gift_record_5';
$poole_type = 5;
}elseif($gift_id == $pool_gift_ids['pool_gift_id_10']){
$table = 'bb_lottery_gift_record_10';
$poole_type = 10;
}else{
$table = 'bb_lottery_gift_record';
$poole_type = 1;
}
foreach ($toarray as $k => $to_id){
// 1. 记录礼物赠送
@@ -70,30 +86,24 @@ class Lottery extends Model
'recv_uid' => $to_id,
'gift_id' => $gift_id,
'gift_gold' => $gift_price,
'recv_gold' => $gift_price /2 ,
'small_pool_add' => $gift_price /2 ,
'create_time' => time()
'recv_gold' => $recv_coin,
'small_pool_add' => $small_pool,
'create_time' => time(),
'remark' => '幸运币收益率'.$lucky_rate.'%'
];
$giftId = Db::name('bb_lottery_gift_record')->insertGetId($giftRecord);
$giftId = Db::name($table)->insertGetId($giftRecord);
//收礼记录行为日志
$give_gift = model('api/SendGift')->change_user_give_gift_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
$give_gift = model('api/SendGift')->change_user_give_gift_logs($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
if(!$give_gift){
Db::rollback();
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
}
//计算收礼人得益
$receiver_earnings = $gift_price /2/get_system_config_value('rmb_coin_ratio');
$receiver_earnings = $recv_coin/get_system_config_value('rmb_coin_ratio');
//增加收益并记录日志
// $receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收幸运币礼增加收益');
$receiver = model('api/UserWallet')->change_user_earnings_log($to_id,$receiver_earnings,$room_id,11,'收幸运币礼增加收益');
$receiver = model('api/UserWallet')->change_user_earnings_log($to_id,$receiver_earnings,$room_id,11,'收幸运币礼增加收益');
// //用户魅力等级更新
// $user_level = model('api/Level')->user_level_data_update($to_id,$gift_price,2,$room_id);
// if(!$user_level){
// Db::rollback();
// return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
// }
//增加房间幸运值
db::name('vs_room')->where(['id' => $room_id])->setInc('luck_value',$gift_price);
db::name('vs_room_luck_value')->insert( [
@@ -125,7 +135,7 @@ class Lottery extends Model
//计算爆币
$nums = $num * count($toarray);
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info);
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info,$poole_type);
if($ress['code'] == 0){
return ['code' => 0, 'msg' => $ress['msg'], 'data' => null];
}
@@ -134,8 +144,76 @@ class Lottery extends Model
}
//抽奖
public function lottery($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null)
//抽奖(不带大奖池)
public function lottery($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null,$poole_type = 1)
{
try {
$gift_gold = $gift_price;
if($poole_type == 5){
$text = '中级';
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
$service = new LotteryService5();
}elseif($poole_type == 10){
$text = '高级';
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'gao_prize_play_image'])->value('value');
$service = new LotteryService10();
}else{
$text = '初级';
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
$service = new LotteryService();
}
for($i=0;$i<$num;$i++){
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
if ($reslut['code'] == 1) {
$result = $reslut['data'];
//(未开奖时)
if ($result['is_small_prize'] == 0) {
//不做处理
} else {//开奖
$beilv = floor($result['small_prize_amount'] / $gift_price);
$small_prize_amount = floor($result['small_prize_amount'] / $gift_price) * $gift_price;
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$small_prize_amount,$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
if(!$wallet_update){
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
}
$tet['text'] = '恭喜用户'.$fromUserInfo['nickname'].'在'.$text.'幸运币活动中获得幸运币'.$beilv.'倍';
$tet['type'] = 2;
$tet['beilv'] = $beilv;
$tet['play_image'] = $small_prize_play_image;
$tet['FromUserInfo'] = $fromUserInfo;
$tet['user_id'] = $send_uid;
model('api/Chat')->sendMsg(1100,$room_id,$tet);
$push = new Push($send_uid, $room_id);
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
$text = '恭喜'.$fromUserInfo['nickname'] . '在' . $room_name . '房间获得'.$text.'幸运币'. $beilv . '倍';
$text_list_new[] = [
'text' => $text,
'gift_picture' => $gift_info['base_image'],
'room_id' => $room_id,
'fromUserName' => $fromUserInfo['nickname'],
'toUserName' => '',
'giftName' => '',
'roomId' => $room_id,
'number' => 1,
];
$push->giftBanner($text_list_new);
}
}
}
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
} catch (Exception $e) {
Log::error('抽奖处理失败:' . $e->getMessage());
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
}
}
//抽奖(带大奖池)
public function lotterys($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null)
{
$big_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
@@ -143,7 +221,7 @@ class Lottery extends Model
for($i=0;$i<$num;$i++){
$gift_gold = $gift_price;
$service = new LotteryService();
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
$reslut = $service->handleGifts($send_uid, $gift_gold, $giftId);
if ($reslut['code'] == 1) {
$result = $reslut['data'];
//(未开奖时)

View File

@@ -0,0 +1,730 @@
<?php
namespace app\api\model;
use app\common\controller\Push;
use think\Db;
use think\Model;
class Monster extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
public static function init()
{
self::beforeWrite(function ($row) {
});
}
//选择金币列表
public function choice_gold_list(){
$list = db::name('monster_multiple')->field('multiple')->select();
$data = [];
$data['list'] = $list;
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//游戏详情
public function get_monster_info($uid){
$config = get_system_config();
$user_info = db::name('user_wallet_coin')->where('user_id', $uid)->field('id,coin')->find();
if(!$user_info){
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
}
$now_time = time();
$data = [];
$data['surplus_time'] = 0;
$data['is_finsh'] = 3;
$data['win_number'] = 0;
// $data['list'] = [];
$data['open_monster_price'] = $config['open_monster_price'];
$data['integral'] = $user_info['coin'];
$data['multiple_list'] = db::name('monster')->field('id,type,type_name,multiple')->order('id asc')->select();
foreach ($data['multiple_list'] as $a => &$b){
$b['num'] = 0;
}
//当前是否有开放该活动
$monster_log = db::name('monster_log')->order('id desc')->limit(1)->find();
if(empty($monster_log)){
return ['code' => 0, 'msg' => '获取成功', 'data' => $data];
}else{
if($monster_log['end_time'] <= $now_time){
$is_finish = 1;
$data['win_number'] = $monster_log['win_type'];
}else{
$is_finish = 2;
$data['surplus_time'] = $monster_log['end_time'] - $now_time;
}
$data['is_finsh'] = $is_finish;
foreach ($data['multiple_list'] as $a => &$b){
$user_monster_feed_log = db::name('user_monster_log')->where('uid', $uid)->where('mid', $monster_log['id'])->where('type', $b['type'])->find();
if(!empty($user_monster_feed_log)){
$b['num'] = $user_monster_feed_log['num'];
}
}
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
}
//生成当前国王游戏期数
public function create_monster_log(){
set_time_limit(0);
ini_set('memory_limit', '1024M');
$config = get_system_config();
$now_time = time();
$is_push = 5;//不推送
Db::startTrans();
try {
$map = [];
$map['is_delete'] = 1;
$monster_log = db::name('monster_log')->where($map)->find();
if($monster_log){//当前有未结束的国王游戏期数
if($now_time >= $monster_log['end_time']){
$key_name = "api:monster:create_monster_log:id".$monster_log['id'];
$redis_order_sn = redis_lock_exits($key_name,1,7);
if(!$redis_order_sn){
return ['code' => 0, 'msg' => '请重试1', 'data' => null];
}
$win_type = $monster_log['win_type'];
$in_amount = 0;
$win_type = $this->check_win_type_is_loss($win_type, $monster_log);
$win_gift_info = db::name('vs_gift')->alias('a')->join('monster b', 'a.gid = b.gid')->where('b.type', $win_type)->field('a.gid,a.gift_name,a.gift_price,a.base_image,b.multiple')->find();
if(!$win_gift_info){
Db::rollback();
return ['code' => 0, 'msg' => '为配置礼物', 'data' => null];
}
//获取得奖用户ID
$map = [];
$map['mid'] = $monster_log['id'];
$part_user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
$map['type'] = $win_type;
$user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
if(!empty($user_array)){
//有获奖用户
$insert_all = [];
foreach ($user_array as $a => $b){
$map = [];
$map['mid'] = $monster_log['id'];
$map['uid'] = $b;
$map['type'] = $win_type;
$user_monster_log = db::name('user_monster_log')->where($map)->find();
$wim_num = floor($user_monster_log['price'] * $win_gift_info['multiple'] / $win_gift_info['gift_price']);
$in_amount += $win_gift_info['gift_price'] * $wim_num;
//礼物送到背包
if($wim_num > 0){
$reslut = model('api/UserGiftPack')->change_user_gift_pack($b, $win_gift_info['gid'], $wim_num, model('UserGiftPack')::LY_DRAW_GIFT_GET, '炼仙传说中奖获取');
if($reslut['code'] == 0){
Db::rollback();
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
}
}
//用户中奖信息
$insert = [];
$insert['uid'] = $b;
$insert['rid'] = $user_monster_log['rid'];
$insert['mid'] = $monster_log['id'];
$insert['win_type'] = $win_type;
$insert['win_gid'] = $win_gift_info['gid'];
$insert['price'] = $user_monster_log['price'];
$insert['num'] = $wim_num;
$insert['createtime'] = time();
$insert_all[] = $insert;
}
$reslut = db::name('user_monster_win_log')->insertAll($insert_all);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '请重试2', 'data' => null];
}
}
//结束当前抽卡期数
$update = [];
$update['win_type'] = $win_type;
$update['in_amount'] = $in_amount;
$update['is_delete'] = 2;
$update['updatetime'] = time();
$reslut = db::name('monster_log')->where('id', $monster_log['id'])->update($update);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '请重试3', 'data' => null];
}
$is_push = 2;
}
}else{//当前未有国王游戏期数
if($config['open_monster_status'] != 1){
Db::rollback();
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
}
//距离上次多长时间
$map = [];
$map['is_delete'] = 2;
$last_monster_log = db::name('monster_log')->where($map)->order('id desc')->limit(1)->find();
if($last_monster_log){
// $interval_time = $last_monster_log['end_time'] + 10 + $config['end_interval_time'];
$interval_time = time() - $last_monster_log['end_time'];
if($interval_time < $config['end_interval_time']){
Db::rollback();
return ['code' => 0, 'msg' => '距离上次结束尚未超过'.$config['end_interval_time'].'秒', 'data' => null];
}
}
//当前国王游戏配置信息
$monster_list = db::name('monster')->order('id asc')->select();
$monster_data = '';
$total_num = 0;
$win_number_data = [];
foreach ($monster_list as $a => $b){
$da = $b['id'].'-'.$b['gid'].'-'.$b['num'].';';
$monster_data .= $da;
$total_num += $b['num'];
for($i = 0; $i < $b['num']; $i++){
$win_number_data[] = $b['id'];
}
}
shuffle($win_number_data);
$win_key = array_rand($win_number_data);
//随机抽取中奖数字
$win_type = $win_number_data[$win_key];
//生成最新
$insert = [];
$insert['win_type'] = $win_type;
$insert['total_num'] = $total_num;
$insert['config_text'] = $monster_data;
$insert['createtime'] = $now_time;
$insert['end_time'] = $now_time + $config['monster_count_down_time'];
$reslut = db::name('monster_log')->insert($insert);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '生成失败', 'data' => null];
}
$is_push = 1;//开启推送
}
Db::commit();
if($is_push == 1){
$push_feed_monster_data = $this->get_new_feed_monster_info();
$push_data = [];
$push_data['code'] = 3031;
$push_data['msg'] = "探索开始播报";
$push_data['data'] = $push_feed_monster_data;
// 推送
$push = new Push();
$push->xianxuan($push_data);
}else if($is_push == 2){
$push_feed_monster_data = $this->get_new_feed_monster_info();
$push_feed_monster_data['win_count'] = count($user_array);
$push_feed_monster_data['game_name'] = '国王游戏';
$push_feed_monster_data['win_type_name'] = db::name('monster')->where('type', $win_type)->value('type_name');
$push_feed_monster_data['gift_name'] = $win_gift_info['gift_name'];
$push_feed_monster_data['num'] = 0;
$push_feed_monster_data['total_gift_price'] = 0;
$push_feed_monster_data['is_push_message'] = 2;
$push_feed_monster_data['base_image'] = localpath_to_netpath($win_gift_info['base_image']);
// if(!empty($part_user_array)){
// foreach ($part_user_array as $k => $v){
// $push_user_monster_data = [];
// $push_user_monster_data['win_type'] = $win_type;
// $push_user_monster_data['type_name'] = db::name('monster')->where('type', $win_type)->value('type_name');
// //是否中奖
// $map = [];
// $map['mid'] = $monster_log['id'];
// $map['uid'] = $v;
// $user_win_info = db::name('user_monster_win_log')->where($map)->find();
// if($user_win_info){//中奖
// $push_user_monster_data['is_win'] = 1;
// $push_user_monster_data['gid'] = $win_gift_info['gid'];
// $push_user_monster_data['gift_name'] = $win_gift_info['gift_name'];
// $push_user_monster_data['base_image'] = localpath_to_netpath($win_gift_info['base_image']);
// $push_user_monster_data['gift_price'] = $win_gift_info['gift_price'];
// $push_user_monster_data['num'] = $user_win_info['num'];
// $push_user_monster_data['total_gift_price'] = $win_gift_info['gift_price'] * $user_win_info['num'];
// $push_feed_monster_data['num'] += $user_win_info['num'];
// $push_feed_monster_data['total_gift_price'] += $push_user_monster_data['total_gift_price'];
// }else{//未中奖
// $push_user_monster_data['is_win'] = 2;
// $push_user_monster_data['gid'] = 0;
// $push_user_monster_data['gift_name'] = '';
// $push_user_monster_data['base_image'] = '';
// $push_user_monster_data['gift_price'] = 0;
// $push_user_monster_data['num'] = 0;
// }
//
// $push_data = [];
// $push_data['code'] = 3032;
// $push_data['msg'] = "抽卡个人结束播报";
// $push_data['data'] = $push_user_monster_data;
// $push = new Push();
// $push->xianxuan($push_data);
// // error_log(date('Y-m-d H:i:s').'_'.$v.'_'.$reslut."\r\n", 3, '1111.txt');
// }
// }
$push_feed_monster_data['num'] = db::name('user_monster_win_log')->where(['mid'=>$monster_log['id']])->sum('num');
if($push_feed_monster_data['num'] > 0){
$push_feed_monster_data['is_push_message'] = 1;
$push_feed_monster_data['total_gift_price'] = $win_gift_info['gift_price'] * $push_feed_monster_data['num'];
}
$push_data = [];
$push_data['code'] = 3033;
$push_data['msg'] = "探索结束播报";
$push_data['data'] = $push_feed_monster_data;
$push = new Push();
$push->xianxuan($push_data);
// $close_data = $this->get_close_monster_win_log();
// $push_colse_data = [];
// $push_colse_data['code'] = 3034;
// $push_colse_data['msg'] = "国王游戏结束播报";
// $push_colse_data['data'] = $close_data;
// model('api/WebSocketPush')->send_to_all($push_colse_data);
}
return ['code' => 1, 'msg' => '成功', 'data' => null];
} catch (\Exception $e) {
// 回滚事务
dump($e);
Db::rollback();
return ['code' => 0, 'msg' => '失败', 'data' => null];
}
}
//是否修改中奖类型
public function check_win_type_is_loss($win_type, $monster_log){
$config = get_system_config();
//当前亏损数值是否大于
$map = [];
$map['is_delete'] = 2;
$map['out_amount'] = ['>', 0];
$now_monster_out_amount = db::name('monster_log')->where($map)->sum('out_amount');//投入
$now_monster_in_amount = db::name('monster_log')->where($map)->sum('in_amount');//产出
//获取得奖用户ID
$map = [];
$map['mid'] = [ '=', $monster_log['id']];
$map['type'] = ['=', $win_type];
$user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
if(!empty($user_array)){
$wim_monster = db::name('monster')->where('type', $win_type)->find();
$in_amount = 0;
foreach ($user_array as $a => $b){
$map = [];
$map['mid'] = ['=', $monster_log['id']];
$map['uid'] = ['=', $b];
$map['type'] = ['=', $win_type];
$user_monster_log = db::name('user_monster_log')->where($map)->find();
//中奖金额
$win_price = $user_monster_log['price'] * $wim_monster['multiple'];
$in_amount += $win_price;
}
$profit = ($now_monster_in_amount + $in_amount) - ($now_monster_out_amount + $monster_log['out_amount']);
if($profit > $config['monster_max_loss_price']){//亏损大于3w
$type_price_1 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 1)->sum('price');
$win_type_amount_1 = $type_price_1 * 2;
$type_price_2 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 2)->sum('price');
$win_type_amount_2 = $type_price_2 * 4;
$type_price_3 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 3)->sum('price');
$win_type_amount_3 = $type_price_3 * 6.5;
$type_price_4 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 4)->sum('price');
$win_type_amount_4 = $type_price_4 * 10;
$type_price_5 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 5)->sum('price');
$win_type_amount_5 = $type_price_5 * 15;
$type_price_6 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 6)->sum('price');
$win_type_amount_6 = $type_price_6 * 20;
// $type_price_6 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 6)->sum('price');
// $win_type_amount_6 = $type_price_6 * 50;
// $win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4, $win_type_amount_5, $win_type_amount_6];
$win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4, $win_type_amount_5, $win_type_amount_6];
// $win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4];
$win_type_min = min($win_type_amount_arr);
// if($win_type_amount_4 == $win_type_min && $win_type_amount_3 == $win_type_min && $win_type_amount_2 == $win_type_min && $win_type_amount_1 == $win_type_min){
// $win_type = rand(1,4);
// }else
if($win_type_amount_1 == $win_type_min){
$win_type = 1;
}else if($win_type_amount_2 == $win_type_min){
$win_type = 2;
}else if($win_type_amount_3 == $win_type_min){
$win_type = 3;
}else if($win_type_amount_4 == $win_type_min){
$win_type = 4;
}else if($win_type_amount_5 == $win_type_min){
$win_type = 5;
}else if($win_type_amount_6 == $win_type_min){
$win_type = 6;
}
}
}
return $win_type;
}
//当前最新探索信息
public function get_new_feed_monster_info(){
$now_time = time();
$data = [];
$data['surplus_time'] = 0;
$data['is_finsh'] = 3;
$data['win_number'] = 0;
// $data['list'] = [];
$data['multiple_list'] = db::name('monster')->field('id,type,type_name,multiple')->order('id asc')->select();
//当前是否有开放该活动
$monster_log = db::name('monster_log')->order('id desc')->limit(1)->find();
if(empty($monster_log)){
return $data;
}else{
if($monster_log['end_time'] <= $now_time){
$is_finish = 1;
$data['win_number'] = $monster_log['win_type'];
}else{
$is_finish = 2;
$data['surplus_time'] = $monster_log['end_time'] - $now_time;
}
$data['is_finsh'] = $is_finish;
}
//当前参与用户探索列表
// $list = db::name('user_monster_feed_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_monster c', 'a.type = c.type')->where('a.mid', $monster_log['id'])->field('a.id,b.uid,b.nick_name,b.base64_nick_name,b.head_pic,c.type_name,a.price')->order('a.id desc')->select();
// foreach ($list as $k => &$v){
// $v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
// $v['head_pic'] = localpath_to_netpath($v['head_pic']);
// }
// $data['list'] = $list;
return $data;
}
//国王游戏
public function open_beat_monster($uid, $rid, $type, $num){
$user_info = db::name('user_wallet_coin')->where('user_id', $uid)->field('id,coin')->find();
if(!$user_info){
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
}
$config = get_system_config();
$now_time = time();
$monster = db::name('monster')->where('type', $type)->find();
if(!$monster){
return ['code' => 0, 'msg' => '当前类型不存在', 'data' => null];
}
//
$map = [];
$map['end_time'] = ['>', time()];
$map['is_delete'] = 1;
$monster_log = db::name('monster_log')->where($map)->find();
if(!$monster_log){
return ['code' => 0, 'msg' => '请等待新一轮开启', 'data' => null];
}else{
$surplus_time = $monster_log['end_time'] - 5;
if($surplus_time < time()){
return ['code' => 0, 'msg' => '最后五秒内无法参与', 'data' => null];
}
}
if($num < 1){
return ['code' => 0, 'msg' => '次数不能小于1', 'data' => null];
}
//该星途已探索多少次数
$map = [];
$map['mid'] = $monster_log['id'];
$map['uid'] = $uid;
$user_type_num = db::name('user_monster_log')->where($map)->column('type');
$map['type'] = $type;
$user_monster_num = db::name('user_monster_log')->where($map)->sum('num');
if($user_monster_num > 0){
if($user_monster_num + $num > $config['open_monster_max_num']){
return ['code' => 0, 'msg' => '该玩法次数已达上限', 'data' => null];
}
}else{
if($num > $config['open_monster_max_num']){
return ['code' => 0, 'msg' => '该玩法次数已达上限', 'data' => null];
}
}
$user_monster_log = db::name('user_monster_log')->where($map)->find();
if(count($user_type_num) >= 6 && !in_array($type, $user_type_num)){
return ['code' => 0, 'msg' => '玩法类型不能大于六个', 'data' => null];
}
// $open_monster_ticket = $config['open_monster_ticket'];
// $pay_ticket = $num * $open_monster_ticket;
// if($user_info['had_ticket_num'] < $pay_ticket){
// return ['code' => 201, 'msg' => '用户剩余门票数不足', 'data' => null];
// }
$money = $num * $config['open_monster_price'];
if($user_info['coin'] < $money){
return ['code' => 0, 'msg' => '金币不足', 'data' => null];
}
Db::startTrans();
try {
//扣除用户金币
$reslut = model('common/UserWallet')->change_user_money($uid, $money, 1, model('common/UserWallet')::LINGXIAN_TRADITION_LOTTERY_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::LINGXIAN_TRADITION_LOTTERY_COIN));
if ($reslut['code'] != 1) {
Db::rollback();
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
}
//是否探索过
if($user_monster_log){//已探索则继续
$update = [];
$update['updatetime'] = time();
$reslut = db::name('user_monster_log')->where('id', $user_monster_log['id'])->inc('num', $num)->inc('price', $money)->update($update);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '请重试', 'data' => null];
}
}else{//未探索则探索
$insert = [];
$insert['uid'] = $uid;
$insert['rid'] = $rid;
$insert['mid'] = $monster_log['id'];
$insert['type'] = $type;
$insert['num'] = $num;
$insert['price'] = $money;
$insert['createtime'] = time();
$reslut = db::name('user_monster_log')->insert($insert);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '请重试', 'data' => null];
}
}
//用户探索记录表
$insert_data = [];
$insert_data['uid'] = $uid;
$insert_data['rid'] = $rid;
$insert_data['mid'] = $monster_log['id'];
$insert_data['type'] = $type;
$insert_data['num'] = $num;
$insert_data['price'] = $money;
$insert_data['createtime'] = time();
$fid = db::name('user_monster_feed_log')->insertGetId($insert_data);
if(!$fid){
Db::rollback();
return ['code' => 0, 'msg' => '请重试', 'data' => null];
}
//计入当期支出累消
$update = [];
$update['updatetime'] = time();
$reslut = db::name('monster_log')->where('id', $monster_log['id'])->inc('out_amount', $money)->update($update);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '请重试', 'data' => null];
}
Db::commit();
$user_data = db::name('user')->where('id', $uid)->find();
$push_feed_monster_data = [];
$push_feed_monster_data['id'] = $fid;
$push_feed_monster_data['uid'] = $uid;
$push_feed_monster_data['nick_name'] = $user_data['nickname']??"";
$push_feed_monster_data['head_pic'] = $user_data['avatar']??"";
$push_feed_monster_data['type'] = $type;
$push_feed_monster_data['type_name'] = db::name('monster')->where('type', $type)->value('type_name');
$push_feed_monster_data['price'] = $money;
$push_feed_monster_data['num'] = db::name('user_monster_log')->where('mid',$monster_log['id'])->where('uid', $uid)->where('type', $type)->sum('num');
// $push_feed_monster_data['pay_ticket'] = $pay_ticket;
$push_feed_monster_data['integral'] = db::name('user_wallet_coin')->where('user_id', $uid)->value('coin');
// $push_data = [];
// $push_data['code'] = 334;
// $push_data['msg'] = "探索公屏播报";
// $push_data['data'] = $push_feed_monster_data;
// model('api/WebSocketPush')->send_to_all($push_data);
return ['code' => 1, 'msg' => '探索成功', 'data' => $push_feed_monster_data];
} catch (\Exception $e) {
// 回滚事务
// dump($e);
Db::rollback();
return ['code' => 0, 'msg' => '探索失败', 'data' => null];
}
}
//规则
public function get_monster_note(){
$config = get_system_config();
$note = $config['monster_feed_note'];
return ['code' => 1, 'msg' => '获取成功', 'data' => $note];
}
//奖池
public function get_monster_box_list(){
$monster_gift_list = db::name('monster')->alias('a')->join('vs_gift b', 'a.gid = b.gid')->field('a.gid,b.base_image,b.gift_name,b.gift_price')->order('b.gift_price asc')->select();
foreach ($monster_gift_list as $k => &$v){
$v['base_image'] = localpath_to_netpath($v['base_image']);
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_gift_list];
}
//开奖记录
public function get_monster_log($uid, $page, $page_limit){
$user_info = db::name('user')->where('id', $uid)->find();
if(!$user_info){
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
}
$map = [];
$map['a.is_delete'] = ['=', 2];
$monster_list = db::name('monster_log')->alias('a')->join('monster b', 'a.win_type = b.type')->field('a.id,a.win_type,b.type_name,a.createtime as add_time')->where($map)->order('a.id desc')->page($page, $page_limit)->select();
foreach ($monster_list as $k => &$v){
$v['is_join'] = 3;
$v['gift_name'] = '';
$v['base_image'] = '';
$v['gift_price'] = 0;
$v['num'] = 0;
$user_monster_log = db::name('user_monster_log')->where('uid', $uid)->where('mid', $v['id'])->find();
if($user_monster_log){
$v['is_join'] = 2;
$user_monster_win_log = db::name('user_monster_win_log')->where('uid', $uid)->where('mid', $v['id'])->find();
if($user_monster_win_log){
$v['is_join'] = 1;
$gift_info = db::name('vs_gift')->find($user_monster_win_log['win_gid']);
$v['gift_name'] = $gift_info['gift_name'];
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
$v['gift_price'] = $gift_info['gift_price'];
$v['num'] = $user_monster_win_log['num'];
}
}
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_list];
}
//我的列表
public function get_user_monster_log($uid, $page, $page_limit){
$user_info = db::name('user')->where('id', $uid)->find();
if(!$user_info){
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
}
// $map = [];
// $map[] = ['a.uid', '=', $uid];
$user_monster_log = db::name('user_monster_win_log')
->alias('a')
->join('user b', 'a.uid = b.id')
->join('monster c', 'a.win_type = c.type')
->join('vs_gift d', 'd.gid = a.win_gid')
->field('a.id,a.mid,b.id as uid,b.nickname,b.avatar,a.win_type,c.type_name,d.gift_name,d.base_image,d.gift_price,a.num,a.createtime as add_time')->order('a.id desc')->page($page, $page_limit)->select();
foreach ($user_monster_log as $k => &$v){
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
$v['nick_name'] = $user_info['nickname'];
$v['head_pic'] = $user_info['avatar'];
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_monster_log];
}
//中奖次数榜单
public function get_monster_winner_num_list($uid, $time){
if(in_array($time, [1,2,3])){
}
$model = db::name('user_monster_win_log')->field('uid, count(id) as win_num');
if($time == 1){
$model = $model->whereTime('add_time', 'today');
}else if($time == 2){
$model = $model->whereTime('add_time', 'week');
}else if($time == 3){
$model = $model->whereTime('add_time', 'month');
}
$list = $model->group('uid')->order('win_num desc, uid asc')->limit(30)->select();
foreach ($list as $k => &$v){
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
$v['nick_name'] = $user_info['nickname'];
$v['head_pic'] = $user_info['avatar'];
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
}
//设置房间期数开关
public function operate_room_monster_show_status($uid, $rid, $is_show_monster_push){
$room_info = db::name('vs_room')-> where('id', $rid)->find();
if(!$room_info){
return ['code' => 0, 'msg' => '该房间不存在', 'data' => null];
}
$room_admin_uid_arr = explode(',', $room_info['room_admin_uid']);
if ($uid != $room_info['room_owner_uid'] && !in_array($uid, $room_admin_uid_arr)) {
return ['code' => 0, 'msg' => '无权限操作', 'data' => null];
}
Db::startTrans();
try {
$update = [];
$update['is_show_monster_push'] = $is_show_monster_push;
$update['update_time'] = time();
$reslut = db::name('room')->where('rid', $rid)->update($update);
if(!$reslut){
Db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
Db::commit();
$data = [];
$data['rid'] = $rid;
$data['is_show_monster_push'] = $is_show_monster_push;
//推送
$push_data = [];
$push_data['code'] = 3035;
$push_data['msg'] = "修改房间期数开关";
$push_data['data'] = $data;
model('api/WebSocketPush')->send_to_group($rid, $push_data);
return ['code' => 1, 'msg' => '修改成功', 'data' => $data];
} catch (\Exception $e) {
// 回滚事务
// dump($e);
Db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
}
}

View File

@@ -129,7 +129,7 @@ class Nobility extends Model
}
//购买爵位
public function buyNobility($user_id,$lid){
public function buyNobility($user_id,$lid,$is_send=0){
$nobility_info = db::name('vs_nobility')
->field('lid,name,pay_price,renew_price,pay_coin,day,renew_coin')
->where('delete_time', 0)
@@ -245,9 +245,11 @@ class Nobility extends Model
$pay_coin = $nobility_info['pay_coin'] ?? 0;
}
if($pay_coin > 0){
$reslut = model('common/UserWallet')->change_user_money($user_id, $pay_coin, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NOBILITY_PURCHASE_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NOBILITY_PURCHASE_COIN));
if (!$reslut) {
return ['code' => 0, 'msg' => '失败', 'data' => null];
if($is_send != 1){
$reslut = model('common/UserWallet')->change_user_money($user_id, $pay_coin, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NOBILITY_PURCHASE_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NOBILITY_PURCHASE_COIN));
if (!$reslut) {
return ['code' => 0, 'msg' => '失败', 'data' => null];
}
}
}
@@ -265,7 +267,7 @@ class Nobility extends Model
//更新装备缓存
$cache_key = 'user_base_info_'.$user_id;
Cache::rm($cache_key);
return ['code' => 1, 'msg' => '成功'];
return ['code' => 1, 'msg' => '成功', 'data' => null];
}
//购买爵位价格

View File

@@ -0,0 +1,338 @@
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Loader;
use think\Log;
use Yzh\YunPay;
class Payment extends Controller
{
//生成订单号
private function createOrderSn() {
$orderSn = strtoupper(date('Ymd', time())).substr(time(), -5).substr(microtime(), 2, 5).sprintf('%02d',
rand(0, 99));
return $orderSn;
}
/**
* APP支付
*/
public function app_pay() {
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信
$user_id = input('user_id', 0);
$money = input('money', 0);
$coin = input('coin', 0);
$type_params = input('type_params', 0);
$type_id = input('type_id', 0);
$nobility_id = input('nobility_id', 0);//'0-购买金币充值其他是爵位id'
if($nobility_id != 0){
$nobility = model('Nobility')->buyNobilityPrice($user_id,$nobility_id);
if($nobility['code'] == 0 || $nobility['data']['price'] != $money){
return V(0, '网络错误,请重新操作!', null);
}
}
if(!$coin && $nobility_id == 0){
$coin = $money * get_system_config_value('rmb_coin_ratio');
}
if (!$user_id) {
return V(0, '请选择充值用户', null);
}
//获取用户的手机号
$user_phone = db::name('user')->where(["id" => $user_id])->value('mobile');
if(!$user_phone){
return V(0, '请先绑定手机号!', null);
}
//获取用户的实名信息
$real_name = db::name('user_auth')->where(["mobile" => $user_phone,'is_real' => 1])->find();
if(!$real_name){
return V(0, '请先实名认证', null);
}
//获取用户的年龄
if(!getAgeId($real_name['card_id'])){
return V(0, '未成年不可充值!', null);
}
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money > 5000) {
return V(0, '请选择正确的充值金额', null);
}
$user_code = db::name('user')->where(["id" => $user_id])->value('user_code');
$title = $nobility_id == 0 ? '充值到app用户'.($user_code ?? "") ."余额!" :'购买爵位';
$order_number = $this->createOrderSn();
$data['order_sn'] = $order_number;
$data['money'] = $money;
$data['coin'] = $coin;
$data['user_id'] = $user_id;
$data['pay_type'] = $type;
$data['createtime'] = time();
$data['remarke'] = $nobility_id == 0 ? '充值到app用户'.($user_code ?? "") ."余额!" :'购买爵位';
$data['type_params'] = $type_params;
$data['type_id'] = $type_id;
$data['nobility_id'] = $nobility_id;
$re = db::name('vs_user_recharge')->insert($data);
if (!$re) {
return V(0, '充值失败', null);
}
if($type == 2){
//引用支付宝sdk
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
$ali = new \AliPay();
$result['ali'] = $ali->aliAppPays($order_number, $money, $title, $user_id);
}elseif($type == 1){
//引用微信sdk
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
$wx = new \WxPay();
$result['wx'] = $wx->WxPayApp($data);
}elseif($type == 4 || $type == 5){
//引用通联sdk
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
$tonglian = new \TongLian();
$result['tl'] = $tonglian->TongLianPay($data, $type);
}
return V(1, 'app支付', $result);
}
//支付宝回调
public function notify_ali() {
//引用支付宝sdk
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
$ali = new \AliPay();
$verify_result = $ali->verify($_POST);
Log::record("支付宝回调信息".json_encode($_POST),"info");
if($verify_result) {//验证成功
//商户订单号
$out_trade_no = $_POST['out_trade_no'];
//支付宝交易号
$trade_no = $_POST['trade_no'];
if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
$where['order_sn']=$out_trade_no;
$where['order_type']=1;
$where['pay_type']=2;
$where['pay_status']=1;
$data=[
'trade_no'=>$trade_no
];
$res = handelCharge($where,$data);
if($res==0){
echo "fail";
return;
}
echo "success"; //请不要修改或删除
return;
}
echo "fail";
}else {
//验证失败
echo "fail";
//写入日志文件
Log::record("支付宝回调验签失败","info");
}
}
//微信回调地址 示例
public function notify_wx() {
//引用微信sdk
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
$wx = new \WxPay();
//验证是否是微信发送且数据完整
$flag = $wx->WxPayNotifyCheck();
if ($flag['status']) {
if ($flag['data']['return_code'] == 'SUCCESS' && $flag['data']['result_code'] == 'SUCCESS') {
$out_trade_no = $flag['data']['out_trade_no'];//订单号
// $payType = $flag['data']['attach']; //商家数据包
// $time_end = strtotime($flag['data']['time_end']); //支付完成时间
$transaction_id = $flag['data']['transaction_id']; //微信支付订单号
//成功后的业务逻辑处理
$where['order_sn']=$out_trade_no;
$where['order_type']=1;//1 充值
$where['pay_type']=1;//1微信2支付宝 3通联支付宝 4通联微信
$where['pay_status']=1;
$data=[
'trade_no'=>$transaction_id
];
$res = handelCharge($where,$data);
if($res==0){
$r_arr['return_code'] = 'FAIL';
$r_arr['return_msg'] = '回调失败';
echo $wx->arrayToXml($r_arr);
die;
}
$r_arr['return_code'] = 'SUCCESS';
$r_arr['return_msg'] = '回调成功';
echo $wx->arrayToXml($r_arr);
die;
}
}
$r_arr['return_code'] = 'FAIL';
$r_arr['return_msg'] = '回调失败';
echo $wx->arrayToXml($r_arr);
die;
}
//通联支付回调地址 示例
public function allinpayNotify() {
$params = array();
foreach($_POST as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键,因为收银宝以后可能会加字段,动态获取可以兼容由于收银宝加字段而引起的签名异常
$params[$key] = $val;
}
if(count($params)<1){//如果参数为空,则不进行处理
echo "error";
exit();
}
//引用通联sdk
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
$tonglian = new \TongLian();
$ree = $tonglian->ValidSign($params);
// Log::record("通联支付回调信息".json_encode($ree),"info");
if($tonglian->ValidSign($params)){//验签成功
Log::record("通联支付回调信息验签成功".json_encode($params),"info");
//此处进行业务逻辑处理
$pay_type =trim($params['trxreserved']);//备注信息remark
$out_trade_no = trim($params['cusorderid']); //商户订单号
$trade_no = trim($params['trxid']); // 交易号
// $gmt_payment = strtotime(trim($_POST['paytime'])); //交易付款时间
//成功后的业务逻辑处理
$where['order_sn']=$out_trade_no;
$where['order_type']=1;//1 充值
$where['pay_type']=$pay_type;//1微信2支付宝 3通联支付宝 4通联微信
$where['pay_status']=1;
$data=[
'trade_no'=>$trade_no
];
$res = handelCharge($where,$data);
if($res==0){
echo "erro";
return;
}
echo "success";
}else{
Log::record("通联支付回调信息验签失败".json_encode($params),"info");
echo "erro";
}
}
/*
* 云账户回调(提现)
*/
public function yun_callback(){
// $data = input("data", "");
// $mess = input("mess", "");
// $timestamp = input("timestamp", "");
// $sign = input("sign", "");
$data = $_POST['data']??"";
$mess = $_POST['mess']??"";
$timestamp = $_POST['timestamp']?? "";
$sign = $_POST['sign']??"";
write_log_redis("yunzhanghu_huidiao_原始数据",$_POST);
$yun_pay = new YunPay();
$result = $yun_pay->yun_callback($data,$mess,$timestamp,$sign);
if($result['code']==1){
$data = $result['data'];
if($data){
if(!isset($data['status'])){
echo 'fail';
die;
}
$status = $data['status'];
switch ($status){
case "1":
// 支付成功(对于支付宝和微信支付是最终状态,对于银行卡大部分情况是终态,小概率会出现"退汇现象",状态由"成功"变为"退汇"
db::name('vs_user_withdrawal')
->where('order_sn',$data['order_id'])
->where('status',4)
->update([
'status' => 6,
'pay_message' => $data['status_message'],
'pay_time' => time(),
'updatetime' => time()
]);
echo "success";
break;
case "2":
// 支付失败(最终状态)
// TODO 更新业务订单状态,提示用户提现失败,若有用户钱包体系,则需将提现金额退回至用户钱包
db::name('vs_user_withdrawal')
->where('order_sn',$data['order_id'])
->where('status',4)
->update([
'status' => 5,
'pay_message' => $data['status_message'],
'pay_time' => time(),
'updatetime' => time()
]);
//支付失败资金退回
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
echo "success";
break;
break;
case "4":
// 订单挂单(中间状态,挂单原因会在订单详细状态信息返回)
// TODO 提示用户提现中其他逻辑如若因余额不足导致的挂单可通知财务及时充值72小时内补足余额后可自动继续支付
echo "success";
break;
case "9":
// 退汇,(最终状态,银行卡渠道特有现象,会先收到"成功"回调,然后再收到"退汇"的回调一般以成功状态间隔24小时以上
// TODO 更新业务订单状态为“退汇”(失败),通知用户提现失败,建议用户更换其他银行卡提现,若有用户钱包体系,则需将提现金额退回至用户钱包
db::name('vs_user_withdrawal')
->where('order_sn',$data['order_id'])
->where('status',4)
->update([
'status' => 5,
'pay_message' => $data['status_message'],
'pay_time' => time(),
'updatetime' => time()
]);
//支付失败资金退回
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
echo "success";
break;
case "15":
// 订单取消,(最终状态,只有挂单的订单才可以取消)
// TODO 更新业务订单状态为“取消”(失败),通知用户提现失败,若有用户钱包体系,则需将提现金额退回至用户钱包
db::name('vs_user_withdrawal')
->where('order_sn',$data['order_id'])
->where('status',4)
->update([
'status' => 5,
'pay_message' => $data['status_message'],
'pay_time' => time(),
'updatetime' => time()
]);
//支付失败资金退回
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
echo "success";
break;
}
}
}else{
echo "fail";
}
}
}

View File

@@ -18,7 +18,7 @@ class Room extends Model
}
//创建房间 创建
public function user_create_room($uid, $room_name,$room_cover,$room_intro,$type = 0,$need_apply=1)
public function user_create_room($uid, $room_name,$room_cover,$room_intro,$type = 0,$need_apply=1,$password = '')
{
$user_mobile = model('api/User')->where('id', $uid)->value('mobile');
if ($user_mobile == null) {
@@ -62,6 +62,9 @@ class Room extends Model
$data['is_open_blind_box_turntable'] = 1;
}
$data['label_id'] = 1;
if(!empty($password)){
$data['room_password'] = $password;
}
}elseif ($type == 7){//互娱房创建的私密电影屋
$data['room_number'] = $this->get_user_code();
$data['type_id'] = 6;//cp电影房
@@ -149,11 +152,8 @@ class Room extends Model
}
//编辑房间
public function user_edit_room($uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id)
public function user_edit_room($uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id,$password)
{
if($room_id <= 0){
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
}
//判断用户是否是房主
$room_info = db::name('vs_room')->where('id', $room_id)->field('user_id')->find();
//判断用户是否是主持
@@ -174,6 +174,11 @@ class Room extends Model
if($room_background_id != null){
$data['room_background'] = $room_background_id;
}
if($password){
$data['room_password'] = $password;
}else{
$data['room_password'] = '';
}
if(!empty($data)){
$reslut = $this->where('id', $room_id)->update($data);
if (!$reslut) {
@@ -227,14 +232,6 @@ class Room extends Model
}
}
// $list = db::name('vs_room')
// ->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value,label_id,is_show_room')
// ->where($map)
// ->order('sort desc,hot_value desc,id asc')
// ->page($page, $page_limit)->select();
$currentTime = date('H:i:s');
$list = db::name('vs_room')
->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value,label_id,is_show_room,start_time,end_time')
->where($map)
@@ -656,8 +653,9 @@ class Room extends Model
//房间总流水2026年以后的
// $total_amount = model('api/RoomDailyIncome')->getIncomeByPeriod($room_id, $stime, $etime);
$total_amount = model('api/GiveGiftBases')->getRoomStatistics_total($room_id, strtotime($stime), strtotime($etime));
var_dump($total_amount);exit;
$total_amount_status = model('api/GiveGiftBases')->getRoomStatistics_total($room_id, strtotime($stime), strtotime($etime));
$total_amount = $total_amount_status['total_stats']['total_price'];
// var_dump($total_amount);exit;
}
//房主总收益
@@ -903,7 +901,7 @@ class Room extends Model
$isBusinessHours = $this-> isBetweenTime($startTime, $endTime, $currentTime);
// 输出结果
if (!$isBusinessHours) {
return ['code' => 0, 'msg' => '当前时间不在营业时间内', 'data' => ''];
return ['code' => 0, 'msg' => '当前时间此房间不在营业时间内', 'data' => ''];
}
}
@@ -911,6 +909,7 @@ class Room extends Model
//1其他房间游戏中不让退出 给前端返回房间ID
//2允许退出强行退出……
$room_user = db::name('vs_room_visitor')->where(['user_id' => $user_id])->order('id desc')->value('room_id');
if ($room_user && $room_user != $room_id) {
//是否在竞拍位
$auctionn = db::name('vs_room_auction')->where(['room_id' => $room_user, 'user_id' => $user_id,'status' => 2])->find();
@@ -957,6 +956,17 @@ class Room extends Model
$this->quit_room($user_id, $room_user,$user_id);
}
}
//查询用户是否在麦上
$room_pit = db::name('vs_room_pit')->where(['user_id' => $user_id])->order('id desc')->value('room_id');
if ($room_pit && $room_pit != $room_id) {
$room_names = db::name('vs_room')->where(['id' => $room_pit])->value('room_name');
return ['code' => 202, 'msg' => '您已经在房间'.$room_names.'中,请先下麦后并退出房间', 'data' => ['room_id' => $room_pit,'msg'=>'您在'.$room_names .'房间游戏中,不支持进入新房间']];
}
if($room['room_password'] != '' && $user_id != $room['user_id']){
return ['code' => 101, 'msg' => '密码房', 'data' => ''];
}
return ['code' => 1,
'msg' => '成功',
'data' => null
@@ -1019,8 +1029,8 @@ class Room extends Model
Cache::set('room_info_' . $room_id, json_encode($room), 7200);
}
if(isset($room['password']) && $user_id != $room['user_id']){
if (empty($password) || $room['password'] != md5($password)) {
if(isset($room['room_password']) && $room['room_password'] != '' && $user_id != $room['user_id']){
if (empty($password) || $room['room_password'] != $password) {
return ['code' => 0, 'msg' => '密码错误', 'data' => ''];
}
}
@@ -1221,7 +1231,10 @@ class Room extends Model
'is_pk' => $room['is_pk'],//1-默认接受PK2不接受',
'last_pk_room_id' => $last_pk_room_id,
'queue_number' => db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count(),
'sexy_coin' => $liao_ta_coin
'sexy_coin' => $liao_ta_coin,
'start_time' => $room['start_time'],
'end_time' => $room['end_time'],
'room_password' => $room['room_password'],
];
//当前用户信息
@@ -1486,7 +1499,10 @@ class Room extends Model
'is_pk' => $room['is_pk'],//1-默认接受PK2不接受',
'last_pk_room_id' => $last_pk_room_id,
'queue_number' => db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count(),
'sexy_coin' => $liao_ta_coin
'sexy_coin' => $liao_ta_coin,
'start_time' => $room['start_time'],
'end_time' => $room['end_time'],
'room_password' => $room['room_password'],
];
//当前用户信息
@@ -2737,7 +2753,7 @@ class Room extends Model
$user_info['is_room_owner'] = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->find() ? 1 : 0;
$user_info['is_follow'] = db::name('user_follow')->where(['user_id' => $uid, 'follow_id' => $user_id,'type' => 1])->find() ? 1 : 0;
//近90天内收到的礼物数量
$user_info['gift_num'] = db::name('vs_give_gift')->where(['gift_user' => $user_id])->whereTime('createtime', '>', strtotime('-90 day'))->sum('number')?? 0;
$user_info['gift_num'] = db::name('user_gift_wall')->where(['user_id' => $user_id])->sum('count')?? 0;
$user_info['qinmi'] = null;
$user_info['zhenai'] = null;
@@ -2927,31 +2943,22 @@ class Room extends Model
//修改房间类型
// $type 1-交友,2-拍卖7-互娱,8-交友(不要了),9-点唱10-签约11-酒吧房
// $type 1-交友,2-拍卖7-互娱9-点唱10-签约11-酒吧房 99-练歌
public function change_room_type($uid,$room_id,$type)
{
if(!$uid || !$room_id || !$type){
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
}
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $uid])->field('id')->find();
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $uid,'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'] == $type && $roomInfo['type_id'] != 1){
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
}
if($roomInfo['type_id'] == 7 && ($roomInfo['step'] == 2 || $roomInfo['step'] == 3)){
return ['code' => 0, 'msg' => '请先结束交友后修改房间类型', 'data' => null];
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];
return ['code' => 0, 'msg' => '请先结束竞拍后修改房间类型', 'data' => null];
}
}
@@ -2960,11 +2967,98 @@ class Room extends Model
}
if($roomInfo['type_id'] == 10 && $roomInfo['sign_type'] != 0){
return ['code' => 0, 'msg' => '请先结束签约在修改房间类型', 'data' => null];
return ['code' => 0, 'msg' => '请先结束签约在修改房间类型', 'data' => null];
}
//开启事务
db::startTrans();
if($roomInfo['type_id'] == 1){
$is_pk = db::name('vs_room_pk')->where(['room_id_a' => $room_id])->where(['status' => ['in',[2,3,4]]])->find();
$is_pk1 = db::name('vs_room_pk')->where(['room_id_b' => $room_id])->where(['status' => ['in',[2,3,4]]])->find();
if($is_pk || $is_pk1){
return ['code' => 0, 'msg' => '请先结束PK再在修改房间类型', 'data' => null];
}
}
$data = [];
//1-交友
if($type == 1 || $type == 3 || $type == 4 || $type == 8){
$data = [
'label_id' => 1,
'type_id' => $type,
'room_up_pit_type' => 1,//1-排麦模式2-自由模式
'is_song' => 1 //1-等待点歌申请
];
}
//拍卖
if($type == 2){
$data = [
'label_id' => 3,
'type_id' => $type,
'room_up_pit_type' => 1,//1-排麦模式2-自由模式
'is_song' => 1 //1-等待点歌申请
];
//清除房间此前的魅力值
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0,'clear_time' => time()]);
}
//(互娱)
if($type == 7){
$data = [
'label_id' => 5,
'type_id' => $type,
'room_up_pit_type' => 1,//1-排麦模式2-自由模式
'step' => 1 //1-等待开始
];
}
//点唱房 (让别人唱歌)
if($type == 9){
$data = [
'label_id' => 6,
'type_id' => $type,
'room_up_pit_type' => 1,//1-排麦模式2-自由模式
];
}
//签约房
if($type == 10){
$data = [
'label_id' => 7,
'type_id' => $type,
'room_up_pit_type' => 1,//1-排麦模式2-自由模式
'sign_type' => 0, //0-等待签约
'is_hot' => 1,//1-等待上热门
];
}
//酒吧房
if($type == 11){
$data = [
'label_id' => 8,
'type_id' => $type,
'room_up_pit_type' => 1,
'room_background' => db::name('vs_room_background')->where(['id' => 11])->value('image_url')
];
}
//练歌房
if($type == 99){
if($roomInfo['type_id'] == 1 && $roomInfo['type_id'] == 2){
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
}
$res1 = model('RoomSong')->agree_song($uid,$room_id,1);
if($res1['code'] == 0){
return ['code' => 0, 'msg' => $res1['msg'], 'data' => null];
}else{
$res = 1;
}
}else{
$res = db::name('vs_room')->where(['id' => $room_id])->update($data);
}
if(!$res){
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
//在麦位上的用户 全部下麦
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id,'user_id' => ['>',0],'pit_number' => ['<>',9]])->select();
@@ -2982,70 +3076,6 @@ class Room extends Model
}
}
$data = [];
//1-交友3、4、8-不要了
if($type == 1 || $type == 3 || $type == 4 || $type == 8){
$data = [
'label_id' => 1,
'type_id' => $type,
'room_up_pit_type' => 1,
'is_song' => 1
];
}
//拍卖
if($type == 2){
$data = [
'label_id' => 3,
'type_id' => $type,
'room_up_pit_type' => 1,
'is_song' => 1
];
}
//(互娱)
if($type == 7){
$data = [
'label_id' => 5,
'type_id' => $type,
'room_up_pit_type' => 1,
];
}
//点唱房 (让别人唱歌)
if($type == 9){
$data = [
'label_id' => 6,
'type_id' => $type,
'room_up_pit_type' => 1,
];
}
//签约房
if($type == 10){
$data = [
'label_id' => 7,
'type_id' => $type,
'room_up_pit_type' => 1,
];
}
//酒吧房
if($type == 11){
$data = [
'label_id' => 8,
'type_id' => $type,
'room_up_pit_type' => 1,
'room_background' => db::name('vs_room_background')->where(['id' => 11])->value('image_url')
];
}
$res = db::name('vs_room')->where(['id' => $room_id])->update($data);
if(!$res){
db::rollback();
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
}
//如果房间正在点唱中,结束点唱
$romm_song = db::name('vs_room_song')->where(['room_id' => $room_id])->order('did desc')->find();
if(isset($romm_song) && ($romm_song['status'] == 1 || $romm_song['status'] == 2)){
@@ -3059,32 +3089,6 @@ class Room extends Model
//申请上麦的全部下麦
model('RoomPit')->clear_apply_pit_list($uid, $room_id);
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8 || $type == 9 || $type == 10 || $type == 11){
//查询拍卖房的状态
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
if($room_auction){
foreach ($room_auction as $v){
model('RoomAuction')->room_auction_end($room_id,$v['auction_id']);
}
}
//拍卖位上是否有人
$an = Cache::get('auction_user_'.$room_id);
if($an){
//拍卖位下麦
model('api/RoomPit')->host_user_pit($uid,$room_id,888,$an,2);
}
}
if($type == 2){
//清除房间此前的魅力值
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0,'clear_time' => time()]);
//10号麦有人就下去
$pit_10 = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 10])->find();
if($pit_10 && $pit_10['user_id'] > 0){
model('RoomPit')->DownPit($pit_10['user_id'], $room_id,10);
}
}
db::commit();
//推送给前端
$text = [
'room_id' => $room_id,
@@ -3836,6 +3840,30 @@ class Room extends Model
$res1 = db::name('vs_room_business_time_log')->insert($data);
if($res && $res1){
Cache::rm('room_info_'.$room_id);
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
}else{
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
}
}
//设置房间密码
public function set_room_password($user_id,$room_id,$password)
{
//判断是否是房主
$room_owner = db::name('vs_room')->where(['id' => $room_id,'user_id' => $user_id])->find();
if(!$room_owner){
return ['code' => 0, 'msg' => '没有权限', 'data' => null];
}
if($password){
$password = md5($password);
}else{
$password = '';
}
$res = db::name('vs_room')->where('id',$room_id)->update(['password' => $password]);
if($res){
Cache::rm('room_info_'.$room_id);
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
}else{
return ['code' => 0, 'msg' => '操作失败', 'data' => null];

View File

@@ -12,7 +12,18 @@ class RoomAuction extends Model
public function room_relation_list($type_id)
{
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where(['type' => $type_id,'delete_time' => 0])->select();
return ['code' => 1, 'msg' => '操作成功','data' => $list];
if($list){
$relation_array = [
'relation_id' => 0,
'name' => '无关系',
'type' => 0,
'icon' => db::name('vs_relation')->where(['id' => 0])->value('icon'),
];
$lists = array_merge([$relation_array], (array)$list);
}else{
$lists = [];
}
return ['code' => 1, 'msg' => '操作成功','data' => $lists];
}
//礼物计算时间

View File

@@ -546,7 +546,7 @@ class RoomPit extends Model
array_unshift($list['special'],$special);
}
if($list['special']){
foreach ($list['special'] as $k => $v){
foreach ($list['special'] as &$v){
//查询用户的爵位
$juewei = model('Nobility')->getUserNobilityInfo($v['user_id']);
if($juewei){

View File

@@ -3,6 +3,7 @@
namespace app\api\model;
use think\Db;
use think\Log;
use think\Model;
class RoomPk extends Model
@@ -33,12 +34,19 @@ class RoomPk extends Model
}
}
//判断发起者是否房间的主持
$is_host = db::name('vs_room_host')->where('room_id', $room_id_a)->where('user_id', $create_user_id)->where(['type' => 1,'delete_time' =>null ])->find();
$owner = db::name('vs_room')->where('id', $room_id_a)->value('user_id');
if (!$is_host && $owner != $create_user_id) {
return ['code' => 0, 'msg' => '您不是此房间的主持人,请联系房主', 'data' => ''];
//判断发起者是否房间的主持
$roomPit = db::name('vs_room_pit')->where(['room_id' => $room_id_a,'pit_number' => 9])->value('user_id');
if ($roomPit != $create_user_id) {
return ['code' => 0, 'msg' => '您不在此房间的主持人麦位请上麦后发起PK', 'data' => ''];
}
//判断自己是否开启了pk
$is_pk2 = db::name('vs_room_pk')->where(['room_id_a' => $room_id_a,'status' => ['in',[1,2,3,4]]])->find();
$is_pk3 = db::name('vs_room_pk')->where(['room_id_b' => $room_id_a,'status' => ['in',[1,2,3,4]]])->find();
if($is_pk2 || $is_pk3){
return ['code' => 0, 'msg' => '您已经开启了PK请勿重复操作', 'data' => ''];
}
//没有接收者
if(!$room_id_b){
$where = [
@@ -166,6 +174,14 @@ class RoomPk extends Model
//判断发起者是否和别人开启了pk
$is_pk = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_a' => $pk_info['room_id_a'],'status' => ['in',[1,2,3,4]]])->find();
$is_pk1 = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_b' => $pk_info['room_id_a'],'status' => ['in',[1,2,3,4]]])->find();
//判断自己是否开启了pk 查看自己所在的房间
$me_room = db::name('vs_room_pit')->where(['user_id' =>$user_id,'pit_number' =>9])->value('room_id');
$is_pk2 = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_a' => $me_room,'status' => ['in',[1,2,3,4]]])->find();
$is_pk3 = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_b' => $me_room,'status' => ['in',[1,2,3,4]]])->find();
if($is_pk2 || $is_pk3){
return ['code' => 0, 'msg' => '您已经开启了PK请勿重复操作', 'data' => ''];
}
if($is_pk || $is_pk1){
return ['code' => 0, 'msg' => '发起方已经重新开启了PK请重新选择PK房间', 'data' => ''];
}
@@ -279,18 +295,18 @@ class RoomPk extends Model
public function search_pk_room($user_id,$room_id,$page,$limit)
{
//自己当前房间
$room_id_a = db::name('vs_room')->where('user_id', $user_id)->value('id');
// $room_id_a = db::name('vs_room')->where('user_id', $user_id)->value('id');
$room_id_b = db::name('vs_room_pit')->where(['pit_number' => 9, 'user_id' => $user_id])->value('room_id') ?? 0;
$room_id_c = [$room_id_a,$room_id_b];
// $room_id_c = [$room_id_a,$room_id_b];
$where = [
'a.id' => ['not in',$room_id_c],
'a.id' => ['<>',$room_id_b],
'a.room_status' => 1,
'a.apply_status' => 2,
'a.is_pk' => 1,
'a.is_show_room' => 1,
// 'a.is_show_room' => 1,
'b.pit_number' => 9,
'b.user_id' => ['<>',0],
'a.type_id' => ['in',[1,3,4,8]],
'a.type_id' => 1,
'a.label_id' => 1,
];
@@ -431,13 +447,15 @@ class RoomPk extends Model
];
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
$Victory_user_ids = db::name('vs_room_ppt')
$Victory_user = db::name('vs_room_pit')
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
->column('user_id');
$Failure_user_ids = db::name('vs_room_ppt')
$Victory_user_ids = implode(',',$Victory_user);
$Failure_user = db::name('vs_room_pit')
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
->column('user_id');
$Draw_user_ids = [];
$Failure_user_ids = implode(',',$Failure_user);
$Draw_user_ids = '';
}elseif($pk_info['create_value_a'] < $pk_info['receive_value_b']){
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => $pk_info['create_user_id']]);
$texta = [
@@ -460,13 +478,15 @@ class RoomPk extends Model
];
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
$Victory_user_ids = db::name('vs_room_ppt')
$Victory_user = db::name('vs_room_pit')
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
->column('user_id');
$Failure_user_ids = db::name('vs_room_ppt')
$Victory_user_ids = implode(',',$Victory_user);
$Failure_user = db::name('vs_room_pit')
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
->column('user_id');
$Draw_user_ids = [];
$Failure_user_ids = implode(',',$Failure_user);
$Draw_user_ids = '';
}else{
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => -1]);
$texta = [
@@ -490,18 +510,20 @@ class RoomPk extends Model
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
$Victory_user = db::name('vs_room_ppt')
$Victory_user = db::name('vs_room_pit')
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
->column('user_id');
$Failure_user = db::name('vs_room_ppt')
$Failure_user = db::name('vs_room_pit')
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
->column('user_id');
$Draw_user_ids = array_merge($Victory_user, $Failure_user);
$Victory_user_ids = [];
$Failure_user_ids = [];
}
//合并字符串
$Draw_user_ids = implode(',', array_unique(array_merge($Victory_user, $Failure_user)));
$Victory_user_ids = '';
$Failure_user_ids = '';
}
Log::record("pk任务平双方".$Draw_user_ids,"info");
//任务35-每日参与PK
model('api/Tasks')->tasks_complete_pk($Victory_user_ids,$Failure_user_ids,$Draw_user_ids,35);
@@ -597,7 +619,12 @@ class RoomPk extends Model
if(strpos($pk_info['close_users'], $user_id) !== false){
return ['code' => 1, 'msg' => '成功', 'data' => ''];
}else{
$close = $pk_info['close_users'] .',' . $user_id;
//查看里面有值吗
if($pk_info['close_users']){
$close = $pk_info['close_users'] .',' . $user_id;
}else{
$close = $user_id;
}
$res = db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['close_users' => $close]);
}
}else{

View File

@@ -91,6 +91,13 @@ class SendGift extends Model
return ['code' => 0, 'msg' => '网络错误-1', 'data' => null];
}
//用户财富等级更新
$user_level = model('api/Level')->user_level_data_update($uid,$gift_price,1,$p_room_id);
if(!$user_level){
Db::rollback();
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
}
}else{
Db::rollback();
return ['code' => 0, 'msg' => '类型错误', 'data' => null];
@@ -248,6 +255,12 @@ class SendGift extends Model
Db::rollback();
return ['code' => 0, 'msg' => '网络错误-1', 'data' => null];
}
//用户财富等级更新
$user_level = model('api/Level')->user_level_data_update($uid,$gift_price,1,$room_id);
if(!$user_level){
Db::rollback();
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
}
}else{
//背包礼物是否充足
@@ -275,7 +288,7 @@ class SendGift extends Model
//查询礼物是否是盲盒
if($gift_info['label'] == 2){//趣味礼物(盲盒)
//前端没传参数补偿
if(!$gift_bag_id){
if($gift_bag_id <= 0){
if($gid == 302){
$gift_bag_id = 7;
}elseif ($gid == 303){
@@ -824,6 +837,13 @@ class SendGift extends Model
Db::rollback();
return ['code' => 0, 'msg' => '网络错误-1', 'data' => null];
}
//用户财富等级更新
$user_level = model('api/Level')->user_level_data_update($uid,$gift_price,1,$room_id);
if(!$user_level){
Db::rollback();
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
}
}else{
//扣除背包礼物并记录日志
$gift_pack = $this -> change_user_gift_pack_log(3,$uid,$gid,$num,'房间送礼');
@@ -836,7 +856,7 @@ class SendGift extends Model
//查询礼物是否是盲盒
if($gift_info['label'] == 2){//趣味礼物(盲盒)
//前端没传参数补偿
if(!$gift_bag_id){
if($gift_bag_id <= 0){
if($gid == 302){
$gift_bag_id = 7;
}elseif ($gid == 303){
@@ -997,16 +1017,7 @@ class SendGift extends Model
}
if($gift_info['label'] == 2) {//趣味礼物(盲盒)
// if($gift_box){
// foreach ($gift_box as $i => $v){
// //记录一下收礼记录
// $give_gift = $this -> change_user_give_gift_logs($uid,$v['gift_id'],$v['gift_price'],1,$to_uid,2,$type,$room_id,'',0,2);
// if(!$give_gift){
// Db::rollback();
// return ['code' => 0, 'msg' => '送礼失败,请重试!!', 'data' => null];
// }
// }
// }
$give_gift = $this -> change_user_give_gift_logs($uid,$gid,$receive_gift_total,$num,$to_uid,2,$type,$room_id,$gift_box_str,0,2);
}else{
//收礼记录行为日志
@@ -1203,7 +1214,8 @@ class SendGift extends Model
$reslut = [
'data' => ['gift_total' => $gift_totalaa,'gift_user_data' =>$gift_user_data,]
];
model('api/Friend')->room_give_gift($uid, $to_array,$room_id,$reslut,$heart_id);
$to_users = implode(',',$to_array);//获取所有接收用户id
model('api/Friend')->room_give_gift($uid, $to_users,$room_id,$reslut,$heart_id);
}
//gift_total:收礼人收礼金币总和交友和参与拍卖使用cp_typecp交友使用gift_user_datacp交友使用
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $room_hotvalue,'gift_user_data' =>null,'cp_type' => null]];
@@ -1471,11 +1483,17 @@ class SendGift extends Model
//获取盲盒配置
if($gift_bag_id){
$gift_bag = db::name("vs_gift_bag")->where(['id'=>$gift_bag_id])->find();
if($gift_bag['status'] ==0){
return ['code' => 0, 'msg' => '当前盲盒已关闭', 'data' => []];
}
if(!$gift_bag){
return ['code' => 0, 'msg' => '当前盲盒不存在', 'data' => []];
}
$periods = $gift_bag['periods'] ?? 0;
$bag_gift = db::name("vs_gift")->where(['gid'=>$gift_id])->find();// 获取盲盒信息
$bag_gift = db::name("vs_gift")->where(['gid'=>$gift_id,'is_show'=>1,'is_can_buy'=>1])->find();// 获取盲盒信息
if(empty($bag_gift)){
return ['code' => 0, 'msg' => '当前盲盒已关闭', 'data' => []];
}
//随机获取一个礼物
$where = [
'gift_bag_id' => $gift_bag_id,

View File

@@ -1,6 +1,7 @@
<?php
namespace app\api\model;
use think\Log;
use think\Model;
use think\Session;
use think\Db;
@@ -121,7 +122,7 @@ class Tasks extends Model
//任务列表
$data = db::name('vs_tasks')
->field('id as task_id,icon,task_name,target_quantity,task_type,jump_type,tasks_bag_id')
->field('id as task_id,icon,task_name,target_quantity,task_type,jump_type,tasks_bag_id,ext')
->where('delete_time',0)
->where('is_active',1)
->order('sort desc,id asc')->select();
@@ -294,7 +295,7 @@ class Tasks extends Model
if($v['task_id'] == 35){
//获胜数量
$user_win_times = $user_daily_tasks['ext'] ?? 0;
$quantity_str = $quantity_str." 胜:".$user_win_times.")场";
$quantity_str = $quantity_str." 胜:".$user_win_times."/".$v['ext'].")场";
}
$v['task_name'] = $v['task_name'].$quantity_str;
$v['jump_type_str'] = $this->jump_type[$v['jump_type']];
@@ -470,43 +471,51 @@ class Tasks extends Model
//PK任务完成
public function tasks_complete_pk($Victory_user_ids,$Failure_user_ids,$Draw_user_ids,$task_id=35){
$current_progress =1;
//查询任务
$task_info = Db::name('vs_tasks')->where('id',$task_id)->where('delete_time',0)->where('is_active',1)->find();
if(empty($task_info)){
return ['code' => 0, 'msg' => '任务不存在或已删除','data' => null];
}
$Victory_user_ids = explode(',',$Victory_user_ids);
$Failure_user_ids = explode(',',$Failure_user_ids);
$Draw_user_ids = explode(',',$Draw_user_ids);
//胜利场次配置
$pk_victory_num = $task_info['ext']??1;
$Victory_user_ids_array = explode(',',$Victory_user_ids);
$Failure_user_ids_array = explode(',',$Failure_user_ids);
$Draw_user_ids_array = explode(',',$Draw_user_ids);
if(empty($Draw_user_ids)){
$user_ids = array_unique(array_merge($Victory_user_ids,$Failure_user_ids));
$user_ids = array_unique(array_merge($Victory_user_ids_array,$Failure_user_ids_array));
}else{
$user_ids = $Draw_user_ids;
$user_ids = array_unique($Draw_user_ids_array);
}
$insert_data = [];
foreach ($user_ids as $user_id) {
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
if ($user_daily_tasks && $user_daily_tasks['is_completed'] == 1) {
return ['code' => 0, 'msg' => '您已完成该任务','data' => null];
Log::record("PK任务完成信息状态".$user_id."".json_encode($user_daily_tasks),"info");
if ($user_daily_tasks && $user_daily_tasks['is_completed'] == 1) {//已完成 不处理
continue;
}
//本次是否获胜
$ext = 0;
if ($user_daily_tasks) {
if(in_array($user_id,$Victory_user_ids)){
if(!empty($Victory_user_ids) && in_array($user_id,$Victory_user_ids_array)){
//获胜数加1
$ext = $user_daily_tasks['ext'] + 1;
}else{
$ext = $user_daily_tasks['ext'];
}
$current_progress = $user_daily_tasks['current_progress'] +$current_progress;
if($current_progress >= $task_info['target_quantity'] && $user_daily_tasks['ext']==1){
$current_progress = $user_daily_tasks['current_progress'] + 1;
if($current_progress >= $task_info['target_quantity'] && $ext >= $pk_victory_num){
$is_completed = 1;
$completion_time = time();
}else{
$is_completed = 0;
$completion_time = null;
}
if($current_progress > $task_info['target_quantity']){
$current_progress = $task_info['target_quantity'];
}
if($ext > $pk_victory_num){
$ext = $pk_victory_num;
}
$reslut = Db::name('vs_tasks_user_daily')->where('id',$user_daily_tasks['id'])->update([
'current_progress' => $current_progress,
'is_completed'=> $is_completed,
@@ -515,7 +524,8 @@ class Tasks extends Model
'updatetime' => time(),
]);
}else{
if(in_array($user_id,$Victory_user_ids)){
$current_progress =1;
if(!empty($Victory_user_ids) && in_array($user_id,$Victory_user_ids_array)){
$ext = 1;
}
$insert_data[] = [
@@ -523,14 +533,15 @@ class Tasks extends Model
'task_id' => $task_id,
'current_progress' => $current_progress,
'tasks_bag_id' => $task_info['tasks_bag_id'],
'is_completed' => 1,
'is_completed' => 0,
'ext' => $ext,
'createtime' => time(),
'updatetime' => time(),
];
}
}
if (!empty($insert_data)) {
$reslut = Db::name('vs_tasks_user_daily')->insert($insert_data);
$reslut = Db::name('vs_tasks_user_daily')->insertAll($insert_data);
if ($reslut) {
return ['code' => 1, 'msg' => '操作成功','data' => null];
} else {

View File

@@ -345,6 +345,7 @@ class Tencent extends Model
);
$curlPost = json_encode($curlPost);
$reslut = $this->tencent_post_url($postUrl, $curlPost);
Log::record("增加群成员".json_encode($reslut),"info");
if($reslut['ActionStatus'] == 'OK'){
return ['code' => 1, 'msg' => '添加成功', 'data' => null];
}else{
@@ -404,23 +405,42 @@ class Tencent extends Model
$im_admin = 'administrator';
$admin_sig = $this->tencent_user_sig_info($im_admin);
$rand = rand(111111111,9999999999);
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
$curlPost = array(
'SyncOtherMachine' => $machine_type,
'From_Account' => strval('u'.$uid),
'To_Account' => strval('u'.$receive_uid),
'MsgRandom' => time(),
'MsgBody' => array(
array(
'MsgType' => 'TIMTextElem',
'MsgContent' => array(
'Text' => $message,
if($uid == 'administrator'){
$from_Account ="administrator";
$curlPost = array(
'SyncOtherMachine' => $machine_type,
'From_Account' => strval($from_Account),
'To_Account' => strval('u'.$receive_uid),
'MsgRandom' => time(),
'SendMsgControl' => ["NoUnread", "NoLastMsg", "NoMsgCheck"],
'MsgBody' => array(
array(
'MsgType' => 'TIMCustomElem',
'MsgContent' => array(
'Data' => $message,
)
)
),
);
}else{
$from_Account ="u".$uid;
$curlPost = array(
'SyncOtherMachine' => $machine_type,
'From_Account' => strval($from_Account),
'To_Account' => strval('u'.$receive_uid),
'MsgRandom' => time(),
'MsgBody' => array(
array(
'MsgType' => 'TIMTextElem',
'MsgContent' => array(
'Text' => $message,
),
),
),
);
}
if($OnlineOnlyFlag == 1){
$curlPost['OnlineOnlyFlag'] = 1;
}

View File

@@ -483,20 +483,31 @@ class User extends Model
if($result){
foreach ($result as $item){
$userInfo = [];
$users = explode(',', $item['give_user_ids']);
foreach ($users as $userId){
$user = db::name('user')->where(['id' => $userId])->field('id user_id,nickname,avatar')->find();
if($user){
$userInfo[] = $user;
$top_users_count = 0;
if($item['give_user_ids'] != null){
$users = json_decode($item['give_user_ids'], true);
if($users && is_array($users)){
foreach ($users as $kk => $user_id){
$userInfo[$kk] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
$userInfo[$kk]['count'] = $user_id['count'];
$top_users_count ++;
}
//用户信息$userInfo 按照数量 count 排序且保留前三个
usort($userInfo, function ($a, $b) {
return $b['count'] - $a['count'];
});
$userInfo = array_slice($userInfo, 0, 3);
}
}
$data[] = [
'top_users_count' => count($users),
'top_users_count' => $top_users_count,//送礼人数
'gift_id' => $item['gift_id'],
'gift_name' => $item['gift_name'],
'gift_price' => $item['gift_price'],
'base_image' => $item['base_image'],
'total_count' => $item['count'],
'total_count' => $item['count'],//总数量
'top_users' => $userInfo
];
}
@@ -518,6 +529,28 @@ class User extends Model
return ['code' => 1, 'msg' => '获取成功', 'data' => $redata];
}
//礼物墙用户列表
public function gift_wall_user_list($uid, $gift_id){
$result = db::name('user_gift_wall')
->where(['user_id' => $uid,'gift_id' => $gift_id])
->field('give_user_ids,count')->find();
$user = [];
$count = $result['count'];
if($result){
$user_list = json_decode($result['give_user_ids'], true);
if($user_list){
foreach ($user_list as $kk => $user_id){
$user[$kk] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
$user[$kk]['count'] = $user_id['count'];
}
}
}
return ['code' => 1, 'msg' => '获取成功', 'data' => ['count' => $count, 'users' =>$user]];
}
//添加用户访问记录
/*
* @param $to_id 被访问对象id
@@ -645,11 +678,7 @@ class User extends Model
//循环插入数据库
db::name('user_album_image')->insert($data);
}
//首次创建相册并上传9张照片【完成任务】
$user_album_image_count = db::name('user_album_image')->where('album_id',$album_id)->count();
if($user_album_image_count >= 9){
model('DailyTasks')->tasks_complete($user_id,14);
}
return ['code' => 1, 'msg' => '添加成功', 'data' => null];
}else{
return ['code' => 0, 'msg' => '图片不能为空', 'data' => null];

View File

@@ -33,8 +33,11 @@ class UserCp extends Model
return 0;
}
//查询收礼人有没有给送礼人送过cp礼物 status0-待回应1-建交成功2-已取消
$res = Db::name('user_cp_find')->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])->find();
if($res){
$res = Db::name('user_cp_find')
->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])
->find();
if($res && $res['createtime'] - 86400 < time()){//24小时内
//创建推送信息1回应送礼 并创建Cp空间
$data = [
'from_user_id' => $from_user_id,
@@ -315,8 +318,12 @@ class UserCp extends Model
];
Db::name('user_cp_gift_log')->insert($datas);
//判断是否升级
$level = Db::name('user_cp_level')->where(['change_value' => ['<=', $yuan_exp + $exp],'deletetime' => 0])
->order('change_value desc')->field('level,pendant_id,rights_icon_id')->find();
$xianzhi = $yuan_exp + $exp;
$level = Db::name('user_cp_level')
->field('level,pendant_id,rights_icon_id')
->where(['change_value' => ['<=', $xianzhi],'deletetime' => 0])
->order('change_value desc')
->find();
if($level['level'] != $zone_level){//登记不一致 (升级)
//修改Cp空间等级
$data['level'] = $level['level'];

View File

@@ -480,14 +480,14 @@ class UserData extends Model
->select();
if($list){
foreach($list as &$item){
if($item['is_show_room'] == 2){ //是否显示房间 1是2否
//查询当前房间是否有主持在麦上
$room_host_info = db::name('vs_room_pit')->where(['room_id' => $item['room_id'], 'pit_number' => 9])->value('user_id');
if($room_host_info == 0){
unset($list[$item]);
continue;
}
}
// if($item['is_show_room'] == 2){ //是否显示房间 1是2否
// //查询当前房间是否有主持在麦上
// $room_host_info = db::name('vs_room_pit')->where(['room_id' => $item['room_id'], 'pit_number' => 9])->value('user_id');
// if($room_host_info == 0){
// unset($list[$item]);
// continue;
// }
// }
$item['label_icon'] = db::name('vs_room_label')->where('id',$item['label_id'])->value('label_icon');
//获取房间用户总数
$item['user_count'] = db::name('vs_room_visitor')->where('room_id',$item['room_id'])->count();
@@ -664,12 +664,7 @@ class UserData extends Model
if($data['bank_card_number']==0){
$data['bank_card_number'] = '';
}
if($data['bank_card']==0){
$data['bank_card'] = '';
}
if($data['open_bank']==0){
$data['open_bank'] = '';
}
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
}

View File

@@ -44,6 +44,8 @@ class UserGiftPack extends Model
const DAILY_SIGN = 12;
//盲盒转盘抽奖所得
const BLANK_BOX_DRAW_GIFT_GET = 13;
//炼仙传说中奖获取
const LY_DRAW_GIFT_GET = 14;
public static function init()
{
@@ -66,7 +68,8 @@ class UserGiftPack extends Model
self::NEW_CHARGE_GIFT => '新人充值好礼',
self::TASK_REWARD => '任务奖励',
self::DAILY_SIGN => '每日签到',
self::BLANK_BOX_DRAW_GIFT_GET => '盲盒转盘抽奖所得'
self::BLANK_BOX_DRAW_GIFT_GET => '盲盒转盘抽奖所得',
self::LY_DRAW_GIFT_GET => '炼仙传说中奖获取'
];
}

View File

@@ -29,7 +29,6 @@ class UserWallet extends Model
if(!isset($uid)){
return ['code' => 301, 'msg' => '登录失效,请重新登录!', 'data' => null];
}
// $user_info = db::name('user_wallet')->where('user_id', $uid)->find();
$user_info['coin'] = db::name('user_wallet_coin')->where('user_id', $uid)->sum('coin');
$user_info['earnings'] = db::name('user_wallet_earnings')->where('user_id', $uid)->sum('earnings');
//获取云账号签约协议
@@ -55,7 +54,7 @@ class UserWallet extends Model
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益22.提现驳回或提现失败返还23.财富等级奖励金币领取24.删除关系扣金币,
// 25.赠送好友金币26.好友转赠所得金币27.小时榜获得金币28.新人充值好礼29.发红包钻石30.抢红包金币31.抢红包钻石32.发红包(金币),
// 33.红包剩余退回金币34-红包剩余退回钻石35-爵位购买赠送金币金币40-后台充值金币41-后台充值钻石42-后台扣除金币43-后台扣除钻石,
//50-签约,51-签约失败退回,52-首次被签约收入53.签约师傅每日返还,54-叛徒补偿55-徒弟收礼返佣56-续约57-签到58-爆币,59-红包手续费
//50-签约,51-签约失败退回,52-首次被签约收入53.签约师傅每日返还,54-叛徒补偿55-徒弟收礼返佣56-续约57-签到58-爆币,59-红包手续费 60-炼仙传说抽奖扣除金币
public function log_list($uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
{
// 时间范围处理
@@ -77,7 +76,7 @@ class UserWallet extends Model
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,40,44,51,57,58];
$map['change_type'] = ['in', $in_out_types];
}else{//2-支出
$in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59];
$in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59,60];
$map['change_type'] = ['in', $in_out_types];
}
@@ -179,7 +178,7 @@ class UserWallet extends Model
if(strlen($coin) - strlen(str_replace('.', '', $coin)) > 1){
return ['code' => 0, 'msg' => '请输入正确的金币数量', 'data' => null];
}
$user_info = db::name('user_wallet')->where('user_id',$uid)->find();
$user_info = db::name('user_wallet_coin')->where('user_id',$uid)->find();
if($user_info['coin'] < $coin){
return ['code' => 0, 'msg' => '金币数量不足', 'data' => null];
}
@@ -234,14 +233,14 @@ class UserWallet extends Model
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益22.提现驳回或提现失败返还23.财富等级奖励金币领取24.删除关系扣金币,
// 25.赠送好友金币26.好友转赠所得金币27.小时榜获得金币28.新人充值好礼29.发红包钻石30.抢红包金币31.抢红包钻石32.发红包(金币),
// 33.红包剩余退回金币34-红包剩余退回钻石35-爵位购买赠送金币金币40-后台充值金币41-后台充值钻石42-后台扣除金币43-后台扣除钻石,
//50-签约,51-签约失败退回,52-首次被签约收入53.签约师傅每日返还,54-叛徒补偿55-徒弟收礼返佣56-续约57-签到58-爆币,59-红包手续费
//50-签约,51-签约失败退回,52-首次被签约收入53.签约师傅每日返还,54-叛徒补偿55-徒弟收礼返佣56-续约57-签到58-爆币,59-红包手续费 60-炼仙传说抽奖扣除金币
//资金操作
public function change_user_cion_log($user_id,$money,$room_id,$change_type,$remarks)
{
//增加用户金币类型
$in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58];
$in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58,44];
//减少用户金币类型
$out_types = [4,7,10,17,20,24,25,32,42,50,56,59];
$out_types = [4,7,10,17,20,24,25,32,42,50,56,59,60];
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->lock(true)->find();
if (!$user_wallet) {

View File

@@ -142,12 +142,6 @@ class UserWithdrawal extends Model
Db::rollback();
return V($reslut['code'],$reslut['msg']);
}
//增加冻结余额
$reslut = Db::name('user_wallet')->where('user_id', $user_id)->setInc('frozen_earnings', $number);
if (!$reslut) {
Db::rollback();
return ['code' => 0, 'msg' => "请重试2", 'data' => null];
}
//修改提现余额
$surplus_earnings = Db::name('user_wallet_earnings')->where('user_id', $user_id)->value('earnings');
if ($surplus_earnings > 0) {
@@ -190,10 +184,6 @@ class UserWithdrawal extends Model
//钻石兑换人民币比例
$diamond_to_rmb_ratio = get_system_config_value('diamond_to_rmb_ratio');
$money = $withdraw_info['money'] * $diamond_to_rmb_ratio; //提现金额转换 人民币转为钻石
$result = db::name('user_wallet')->where('user_id', $withdraw_info['user_id'])->setDec('frozen_earnings', $money);
if (!$result) {
return ['code' => 0, 'msg' => '提现失败'];
}
//归还账户余额
$reslut = model('common/UserWallet')->change_user_money($withdraw_info['user_id'], $money, model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::WITHDRAW_FAILURE,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::WITHDRAW_FAILURE));
if ($reslut['code'] != 1) {

View File

@@ -49,25 +49,15 @@ class UserZone extends Model
$res = db::name('user_zone_topic')->insert($datad);
}
}
//判断是不是第一次发布
$count = db::name('user_zone')->where('user_id' , $uid)->count();
if($count <= 1){
//首次发布动态【完成任务】
model('DailyTasks')->tasks_complete($uid,12);
}
//发布的是几张 图片
$count_images = count(explode(',', $images));
if($count_images == 9){
$first = db::name('vs_user_zone_manjiujiang')->where('user_id' , $uid)->find();
if(!$first){
//发布动态头图上传满九张【完成任务】第一次给奖励
model('DailyTasks')->tasks_complete($uid,13);
db::name('vs_user_zone_manjiujiang')->insert(['user_id' => $uid, 'createtime' =>time()]);
}
}
//注册后累计发布M条动态奖励X金币 【完成任务】
model('DailyTasks')->tasks_complete($uid,16);
return ['code' => 1, 'msg' => '发布成功', 'data' => null];
} else {
@@ -92,7 +82,7 @@ class UserZone extends Model
}
$map['a.show_status'] = 1;//1:显示 0不显示
$map['a.is_delete'] = 1;//是否删除 1否2是
// $map['b.status'] = ['<>',0];//是否注销 1正常2禁止登录0注销
$map['b.status'] = ['<>',0];//是否注销 1正常2禁止登录0注销
$order_string = 'a.createtime desc'; //排序规则
@@ -300,14 +290,7 @@ class UserZone extends Model
Db::rollback();
return ['code' => 0, 'msg' => '请重试,', 'data' => null];
}
//评论別人的帖子- 每天第一条奖励【完成任务】
// if($info['user_id'] != $uid){
//今天的第一条评论奖励
$first_comment = db::name('user_zone_comment')->where(['user_id' => $uid, 'createtime' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]])->count();
if ($first_comment ==1) {
model('api/DailyTasks')->tasks_complete($uid,5);
}
// }
//增加评论数量
$reslut = db::name('user_zone')->where('id', $zid)->setInc('comment_num', 1);
if (!$reslut) {

View File

@@ -1212,7 +1212,7 @@ function handelCharge($where,$data){
//活动
if($orderModel['type_id'] == 6){
$orderModel['type_params'] = 2;
}elseif(in_array($orderModel['type_id'],[14,15,16])){
}elseif(in_array($orderModel['type_id'],[14,15,16,17])){
$orderModel['type_params'] = 3;
}
switch ($orderModel['type_params']){

View File

@@ -78,7 +78,7 @@ class BaseCom extends Controller
if (empty($token)) {
// 3. Token为空拒绝访问
return V(0, 'Token不能为空');
return V(301, 'Token不能为空');
}
// 4. 核心验证检查Token是否有效

View File

@@ -77,6 +77,8 @@ class Push
const PUSH_ROOM_PAN_HOUR_PROGRESS = 8001;
//红包
const PUSH_ROOM_PAN_RED_PROGRESS = 8002;
//炼仙传说
const PUSH_ROOM_PAN_XLXS_PROGRESS = 8003;
public $user_id, $room_id, $topic_room, $topic_client;
@@ -315,6 +317,12 @@ class Push
$this->push(self::PUSH_ROOM_PAN_RED_PROGRESS, $topic, $data);
}
//炼仙传说
public function xianxuan($data){
$topic = 'qx_xianxuan';
$this->push(self::PUSH_ROOM_PAN_XLXS_PROGRESS, $topic, $data);
}
// =========================================项目使用结束=====================================================

View File

@@ -8,50 +8,39 @@ class LotteryGiftLua
public static function getLotteryLuaScript()
{
return <<<LUA
-- 接收参数send_uid, recv_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
-- 接收参数send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
local send_uid = ARGV[1]
local recv_uid = ARGV[2]
local gift_gold = tonumber(ARGV[3])
local small_trigger_times = tonumber(ARGV[4])
local big_threshold = tonumber(ARGV[5])
local small_round = tonumber(ARGV[6]) -- 小奖池当前轮次
local big_round = tonumber(ARGV[7]) -- 大奖池当前轮次
local big_total_gold = tonumber(ARGV[8]) -- 大奖池当前轮次金额
-- 核心约束:强制小轮次 ≥ 大轮次
if small_round < big_round then
small_round = big_round
end
local gift_gold = tonumber(ARGV[2])
local small_trigger_times = tonumber(ARGV[3]) or 200 -- 小奖池触发次数
local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次
local lucky_rate = tonumber(ARGV[5]) -- 收益率
local lottery_rate = tonumber(ARGV[6]) -- 爆币率
-- 1. 基础金额拆分
local recv_gold = gift_gold * 0.5
local small_pool_add = gift_gold * 0.5
local recv_gold = gift_gold * lucky_rate / 100
local pool_add_rate = 100 - lucky_rate
local small_pool_add = gift_gold * pool_add_rate / 100
-- 2. Redis键定义
local small_round_key = "lottery:small_pool:round"
local small_total_times_key = "lottery:small_pool:total_times"
local small_total_gold_key = "lottery:small_pool:total_gold"
local big_round_key = "lottery:big_pool:round"
local big_total_gold_key = "lottery:big_pool:total_gold"
-- 初始化轮次确保Redis与入参一致
redis.call('set', small_round_key, small_round)
redis.call('set', big_round_key, big_round)
-- 初始化大奖池金额
if big_total_gold == 0 or big_total_gold == nil then
big_total_gold = tonumber(redis.call('get', big_total_gold_key) or 0)
end
-- 3. 小奖池累计更新
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
small_total_gold = math.floor((small_total_gold + small_pool_add) * 100) / 100
redis.call('set', small_total_gold_key, small_total_gold)
small_total_gold = small_total_gold + small_pool_add
local small_total_golds = string.format("%.2f", small_total_gold)
redis.call('set', small_total_gold_key, small_total_golds)
-- 4. 返回结果初始化(区分大小轮次)
local result = {
send_uid = send_uid,
recv_uid = recv_uid,
gift_gold = gift_gold,
recv_gold = recv_gold,
small_pool_add = small_pool_add,
@@ -59,71 +48,22 @@ local result = {
small_total_gold = small_total_gold,
is_small_prize = 0,
small_prize_amount = 0,
small_remain_amount = 0,
is_big_prize = 0,
big_prize_amount = 0,
big_release_amount = 0,
small_round = small_round, -- 小奖池轮次
big_round = big_round, -- 大奖池轮次
big_total_gold = big_total_gold,
-- 新增:记录要划入下一轮的小奖开奖金额
small_prize_to_big_next_round = 0
}
-- 5. 小奖池开奖判断(小轮次+1
if small_total_times >= small_trigger_times then
result.is_small_prize = 1
-- 小奖随机比例
local small_ratio = math.random(2, 99)
local small_ratio = math.random(2, lottery_rate)
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
-- 小奖剩余金额(划入大奖池当前轮次)
result.small_remain_amount = math.floor((small_total_gold - result.small_prize_amount) * 100) / 100
-- 重置小奖池,小轮次+1
redis.call('set', small_total_times_key, 0)
redis.call('set', small_total_gold_key, 0)
small_round = small_round + 1
redis.call('set', small_round_key, small_round)
result.small_round = small_round
-- 6. 小奖剩余划入大奖池当前轮次
big_total_gold = math.floor((big_total_gold + result.small_remain_amount) * 100) / 100
redis.call('set', big_total_gold_key, big_total_gold)
result.big_total_gold = big_total_gold
-- 7. 大奖池开奖判断(大轮次+1
if big_total_gold >= big_threshold then
result.is_big_prize = 1
-- 大奖比例权重
local weight_sum = 20 + 50 + 30
local random_weight = math.random(1, weight_sum)
local big_ratio = random_weight <= 20 and 60 or (random_weight <= 70 and 70 or 80)
-- 大奖金额
result.big_prize_amount = math.floor(big_total_gold * big_ratio / 100 * 100) / 100
result.big_release_amount = math.floor((big_total_gold - result.big_prize_amount) * 100) / 100
-- 原有逻辑:重置大奖池,大轮次+1
redis.call('set', big_total_gold_key, 0)
big_round = big_round + 1
redis.call('set', big_round_key, big_round)
-- 强制保证小轮次≥大轮次
if small_round < big_round then
small_round = big_round
redis.call('set', small_round_key, small_round)
result.small_round = small_round
end
result.big_round = big_round
result.big_total_gold = 0
-- ===================== 新增核心逻辑 =====================
-- 小奖开奖金额累加到大奖池下一轮次新的big_round
result.small_prize_to_big_next_round = result.small_prize_amount
-- 原子性更新大奖池下一轮次金额
local new_big_total_gold = math.floor(result.small_prize_amount * 100) / 100
redis.call('set', big_total_gold_key, new_big_total_gold)
result.big_total_gold = new_big_total_gold
-- ======================================================
end
end
-- 返回结果
@@ -132,6 +72,145 @@ LUA;
}
// 获取Lua脚本
public static function getLotteryLuaScript5()
{
return <<<LUA
-- 接收参数send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
local send_uid = ARGV[1]
local gift_gold = tonumber(ARGV[2])
local small_trigger_times = tonumber(ARGV[3]) or 200 -- 小奖池触发次数
local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次
local lucky_rate = tonumber(ARGV[5]) -- 收益率
local lottery_rate = tonumber(ARGV[6]) -- 爆币率
-- 1. 基础金额拆分
local pool_add_rate = 100 - lucky_rate -- 累加金币率
local small_pool_add = gift_gold * pool_add_rate / 100 -- 累加金币
-- 2. Redis键定义
local small_round_key = "lottery:small_pool:round_5"
local small_total_times_key = "lottery:small_pool:total_times_5"
local small_total_gold_key = "lottery:small_pool:total_gold_5"
-- 初始化轮次确保Redis与入参一致
redis.call('set', small_round_key, small_round)
-- 3. 小奖池累计更新
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
small_total_gold = small_total_gold + small_pool_add
local small_total_golds = string.format("%.2f", small_total_gold)
redis.call('set', small_total_gold_key, small_total_golds)
-- 4. 返回结果初始化(区分大小轮次)
local result = {
send_uid = send_uid,
gift_gold = gift_gold,
small_pool_add = small_pool_add,
small_total_times = small_total_times,
small_total_gold = small_total_gold,
is_small_prize = 0,
small_prize_amount = 0,
small_round = small_round, -- 小奖池轮次
}
-- 5. 小奖池开奖判断(小轮次+1
if small_total_times >= small_trigger_times then
result.is_small_prize = 1
-- 小奖随机比例
local small_ratio = math.random(2, lottery_rate)
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
-- 重置小奖池,小轮次+1
redis.call('set', small_total_times_key, 0)
redis.call('set', small_total_gold_key, 0)
small_round = small_round + 1
redis.call('set', small_round_key, small_round)
result.small_round = small_round
end
-- 返回结果
return cjson.encode(result)
LUA;
}
// 获取Lua脚本
public static function getLotteryLuaScript10()
{
return <<<LUA
-- 接收参数send_uid, gift_gold, small_trigger_times, big_threshold, small_round, big_round, big_total_gold
local send_uid = ARGV[1]
local gift_gold = tonumber(ARGV[2])
local small_trigger_times = tonumber(ARGV[3]) or 200 -- 小奖池触发次数
local small_round = tonumber(ARGV[4]) -- 小奖池当前轮次
local lucky_rate = tonumber(ARGV[5]) -- 收益率
local lottery_rate = tonumber(ARGV[6]) -- 爆币率
-- 1. 基础金额拆分
local pool_add_rate = 100 - lucky_rate
local small_pool_adds = gift_gold * pool_add_rate / 100
local small_pool_add = string.format("%.2f", small_pool_adds)
-- 2. Redis键定义
local small_round_key = "lottery:small_pool:round_10"
local small_total_times_key = "lottery:small_pool:total_times_10"
local small_total_gold_key = "lottery:small_pool:total_gold_10"
-- 初始化轮次确保Redis与入参一致
redis.call('set', small_round_key, small_round)
-- 3. 小奖池累计更新
local small_total_times = tonumber(redis.call('incr', small_total_times_key))
local small_total_gold = tonumber(redis.call('get', small_total_gold_key) or 0)
small_total_gold = small_total_gold + small_pool_add
local small_total_golds = string.format("%.2f", small_total_gold)
redis.call('set', small_total_gold_key, small_total_golds)
-- 4. 返回结果初始化(区分大小轮次)
local result = {
send_uid = send_uid,
gift_gold = gift_gold,
small_pool_add = small_pool_add,
small_total_times = small_total_times,
small_total_gold = small_total_gold,
is_small_prize = 0,
small_prize_amount = 0,
small_round = small_round, -- 小奖池轮次
}
-- 5. 小奖池开奖判断(小轮次+1
if small_total_times >= small_trigger_times then
result.is_small_prize = 1
-- 小奖随机比例
local small_ratio = math.random(2, lottery_rate)
result.small_prize_amount = math.floor(small_total_gold * small_ratio / 100 * 100) / 100
-- 重置小奖池,小轮次+1
redis.call('set', small_total_times_key, 0)
redis.call('set', small_total_gold_key, 0)
small_round = small_round + 1
redis.call('set', small_round_key, small_round)
result.small_round = small_round
end
-- 返回结果
return cjson.encode(result)
LUA;
}
// 获取Lua脚本
public static function getLotteryLuaScripts()
{

View File

@@ -555,8 +555,8 @@ class GiveGiftBase extends Model
return [];
}
}
/**
* 统计收礼用户 的送礼用户的分组和
* @param array $where 查询条件
@@ -631,7 +631,7 @@ class GiveGiftBase extends Model
// 最终统计
if ($options['group_by']) {
$finalSql = "SELECT {$options['group_by']},
SUM(total_price) * 10 as total
SUM(total_price) as total
FROM ({$unionSql}) as tmp
GROUP BY {$options['group_by']}
ORDER BY total desc";

View File

@@ -54,7 +54,7 @@ class Redpacket extends Model
$fee = get_system_config_value('red_packet_fee') ?? 0;
// 验证用户余额
$wallet = Db::name('user_wallet')->where('user_id', $data['user_id'])->find();
$wallet = Db::name('user_wallet_coin')->where('user_id', $data['user_id'])->find();
$coinField = $data['coin_type'] == self::COIN_GOLD ? 'coin' : 'earnings';
if($data['total_amount'] < $minAmount){
@@ -64,36 +64,40 @@ class Redpacket extends Model
return ['code' => 0, 'msg' => '余额不足', 'data' => null];
}
$res = model('api/UserWallet')->change_user_cion_log($data['user_id'],$data['total_amount'],$data['room_id'],32,'金币(发红包)');
$delres = model('api/UserWallet')->change_user_cion_log($data['user_id'],$fee,$data['room_id'],59,'红包手续费');
// 扣除余额
$delres = Db::name('user_wallet')
->where('user_id', $data['user_id'])
->dec($coinField, $data['total_amount']+$fee)
->update();
//记录日志 32-发红包金币29-发红包钻石30-抢红包金币31-抢红包(钻石)
//记录用户金币日志
$data_log = [
'user_id' => $data['user_id'],
'change_value' => $data['total_amount'],
'room_id' => $data['room_id'],
'money_type' => $data['coin_type'],
'change_type' => $data['coin_type'] == self::COIN_GOLD ? 32 : 29,
'from_id' => $data['room_id'],
'remarks' => $data['coin_type'] == self::COIN_GOLD ? '金币(发红包)' : '钻石(发红包)',
'createtime' => time()
];
$res = Db::name('vs_user_money_log')->insert($data_log);
// $delres = Db::name('user_wallet')
// ->where('user_id', $data['user_id'])
// ->dec($coinField, $data['total_amount']+$fee)
// ->update();
// //记录日志 32-发红包金币29-发红包钻石30-抢红包金币31-抢红包(钻石)
// //记录用户金币日志
// $data_log = [
// 'user_id' => $data['user_id'],
// 'change_value' => $data['total_amount'],
// 'room_id' => $data['room_id'],
// 'money_type' => $data['coin_type'],
// 'change_type' => $data['coin_type'] == self::COIN_GOLD ? 32 : 29,
// 'from_id' => $data['room_id'],
// 'remarks' => $data['coin_type'] == self::COIN_GOLD ? '金币(发红包)' : '钻石(发红包)',
// 'createtime' => time()
// ];
// $res = Db::name('vs_user_money_log')->insert($data_log);
//记录手续费日志
$data_log = [
'user_id' => $data['user_id'],
'change_value' => $fee,
'room_id' => $data['room_id'],
'money_type' => $data['coin_type'],
'change_type' => model('common/UserWallet')::RED_PACKET_FEE ,
'from_id' => $data['room_id'],
'remarks' => model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::RED_PACKET_FEE),
'createtime' => time()
];
$res = Db::name('vs_user_money_log')->insert($data_log);
// $data_log = [
// 'user_id' => $data['user_id'],
// 'change_value' => $fee,
// 'room_id' => $data['room_id'],
// 'money_type' => $data['coin_type'],
// 'change_type' => model('common/UserWallet')::RED_PACKET_FEE ,
// 'from_id' => $data['room_id'],
// 'remarks' => model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::RED_PACKET_FEE),
// 'createtime' => time()
// ];
// $res = Db::name('vs_user_money_log')->insert($data_log);
if(!$res || !$delres){
Db::rollback();

View File

@@ -123,6 +123,8 @@ class UserWallet extends Model
const BACKGROUND_DEDUCTION_DIAMOND = 43;
//公会会员付费退出会长收入
const GUILD_EXIT_DEACON_INCOME = 44;
//炼仙传说抽奖扣除金币
const LINGXIAN_TRADITION_LOTTERY_COIN = 60;
//金币支出类型数组
@@ -139,8 +141,9 @@ class UserWallet extends Model
self::RENEWAL,
self::RED_PACKET_FEE,
self::BACKGROUND_DEDUCTION_COIN,
self::LINGXIAN_TRADITION_LOTTERY_COIN,
];
//钻石支出类型数组
public $diamond_consumption_type_array = [
self::OPERATION_WITHDRAW,
@@ -219,7 +222,8 @@ class UserWallet extends Model
self::BACKGROUND_RECHARGE_DIAMOND => '后台充值钻石',
self::BACKGROUND_DEDUCTION_COIN => '后台扣除金币',
self::BACKGROUND_DEDUCTION_DIAMOND => '后台扣除钻石',
self::GUILD_EXIT_DEACON_INCOME => "公会会员付费退出会长收入"
self::GUILD_EXIT_DEACON_INCOME => "公会会员付费退出会长收入",
self::LINGXIAN_TRADITION_LOTTERY_COIN => '炼仙传说抽奖扣除金币',
];
if ($type) {
return $status[$type] ?? '';

View File

@@ -104,6 +104,101 @@ class LotteryService
throw new Exception('参数错误');
}
// 读取配置+独立轮次
$small_trigger_times = intval($this->config['small_pool_trigger_times'] ?? 200);//触发抽奖次数
$small_round = intval($this->redis->get('lottery:small_pool:round') ?: 1);//小奖轮次
$lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率
$lottery_rate = intval($this->config['lottery_rate'] ?? 100);//爆币率
if($lottery_rate <= 2){
throw new Exception('配置错误');
}
// 加载Lua脚本
$luaSha = LotteryGiftLua::getLotteryLuaScript();
// 执行Lua脚本入参small_round + big_round
$result = $this->redis->eval($luaSha, [
$send_uid,
$gift_gold,
$small_trigger_times,
$small_round,
$lucky_rate,
$lottery_rate
], 0);
$result = json_decode($result, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception('Lua脚本执行失败');
}
// 开启数据库事务
Db::startTrans();
try {
// . 1记录小奖池累计流水未开奖时
if ($result['is_small_prize'] == 0) {
$this->addPoolFlow(
1, // 小奖池
1, // 累计
$result['small_pool_add'],
$result['small_total_gold'] - $result['small_pool_add'],
$result['small_total_gold'],
$giftId,
$result['small_round'], // 新增:传入轮次
"小奖池累计:用户{$send_uid}送礼,轮次{$result['small_round']}"
);
} else {
$winnerUid = $send_uid; // 奖默认给当前送礼用户
// 小奖中奖记录
$this->addWinnerRecord(
$winnerUid,
1, // 小奖
$result['small_prize_amount'],//中奖金额
$result['small_total_gold'],//奖池总金额
$this->getSmallRatio($result['small_prize_amount'], $result['small_total_gold']),//中奖比例
$result['small_total_gold'] - floor($result['small_prize_amount']) //释放金额
);
// 3. 小奖池开奖流水
$this->addPoolFlow(
1, // 小奖池
2, // 开奖扣除
$result['small_prize_amount'],
$result['small_total_gold'],
$result['small_total_gold'] - $result['small_prize_amount'],
$giftId,
$result['small_round'] - 1, // 开奖轮次为当前轮次-1已结束的轮次
"小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币"
);
}
Db::commit();
return [
'code' => 1,
'msg' => '处理成功',
'data' => $result
];
} catch (Exception $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
/**
* 处理送礼抽奖逻辑 (带大奖池)
* @param int $send_uid 送礼用户ID
* @param float $gift_gold 礼物金币数
* @param int $giftId 礼物ID
* @return array 处理结果
* @throws Exception
*/
public function handleGifts($send_uid, $gift_gold, $giftId)
{
// 参数校验
if ($gift_gold <= 0 || !$send_uid) {
throw new Exception('参数错误');
}
// 读取配置+独立轮次+大奖池金额
$small_trigger_times = intval($this->config['small_pool_trigger_times'] ?? 200);
$big_threshold = floatval($this->config['big_pool_threshold'] ?? 1000);

View File

@@ -0,0 +1,253 @@
<?php
namespace app\common\service;
use app\common\library\LotteryGiftLua;
use think\Cache;
use think\Db;
use think\Exception;
class LotteryService10
{
// Redis实例
private $redis;
// 配置参数
private $config;
public function __construct()
{
$this->redis = Cache::store('redis')->handler();
// 加载配置
$this->config = Db::name('bb_lottery_config')->column('value', 'key');
// 初始化Redis缓存若Redis数据丢失从数据库恢复
$this->initRedisFromDb();
}
/**
* 缓存恢复:独立恢复大小轮次+对应金额
*/
private function initRedisFromDb()
{
// 1. 恢复小奖池轮次取pool_type=1的最大times
$maxSmallRound = Db::name('bb_lottery_pool_flow_10')->where('pool_type', 1)->max('times') ?: 1;
if (!$this->redis->get('lottery:small_pool:round_10')) {
$this->redis->set('lottery:small_pool:round_10', $maxSmallRound);
}
// 2. 恢复小奖池当前轮次的次数/金额
$small_round = intval($this->redis->get('lottery:small_pool:round_10'));
if (!$this->redis->get('lottery:small_pool:total_times_10')) {
$smallTotalTimes = Db::name('bb_lottery_pool_flow_10')
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
->count();
$this->redis->set('lottery:small_pool:total_times_10', $smallTotalTimes);
}
if (!$this->redis->get('lottery:small_pool:total_gold_10')) {
$smallTotalGold = Db::name('bb_lottery_pool_flow_10')
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
->sum('amount') ?: 0;
$this->redis->set('lottery:small_pool:total_gold_10', $smallTotalGold);
}
}
/**
* 处理送礼抽奖逻辑
* @param int $send_uid 送礼用户ID
* @param float $gift_gold 礼物金币数
* @param int $giftId 礼物ID
* @return array 处理结果
* @throws Exception
*/
public function handleGift($send_uid, $gift_gold, $giftId)
{
// 参数校验
if ($gift_gold <= 0 || !$send_uid) {
throw new Exception('参数错误');
}
// 读取配置+独立轮次
$small_trigger_times = intval($this->config['small_pool_trigger_times_10'] ?? 200);//触发抽奖次数
$small_round = intval($this->redis->get('lottery:small_pool:round_10') ?: 1);//小奖轮次
$lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率
$lottery_rate = intval($this->config['lottery_rate_10'] ?? 100);//爆币率
if($lottery_rate <= 2){
throw new Exception('配置错误');
}
// 加载Lua脚本
$luaSha = LotteryGiftLua::getLotteryLuaScript10();
// 执行Lua脚本入参small_round + big_round
$result = $this->redis->eval($luaSha, [
$send_uid,
$gift_gold,
$small_trigger_times,
$small_round,
$lucky_rate,
$lottery_rate
], 0);
$result = json_decode($result, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception('Lua脚本执行失败');
}
// 开启数据库事务
Db::startTrans();
try {
// . 1记录小奖池累计流水未开奖时
if ($result['is_small_prize'] == 0) {
$this->addPoolFlow(
1, // 小奖池
1, // 累计
$result['small_pool_add'],
$result['small_total_gold'] - $result['small_pool_add'],
$result['small_total_gold'],
$giftId,
$result['small_round'], // 新增:传入轮次
"小奖池累计:用户{$send_uid}送礼,轮次{$result['small_round']}"
);
} else {
$winnerUid = $send_uid; // 奖默认给当前送礼用户
//中奖金额
$prizeAmount = floor($result['small_prize_amount'] / $gift_gold) * $gift_gold;
// 小奖中奖记录
$this->addWinnerRecord(
$winnerUid,
4, // 高级奖池
$prizeAmount,//中奖金额
$result['small_total_gold'],//奖池总金额
$this->getSmallRatio($result['small_prize_amount'], $result['small_total_gold']),//中奖比例
$result['small_total_gold'] - $prizeAmount //释放金额
);
// 3. 小奖池开奖流水
$this->addPoolFlow(
1, //
4, //
$prizeAmount,
$result['small_total_gold'],
$result['small_total_gold'] - $prizeAmount,
$giftId,
$result['small_round'] - 1, // 开奖轮次为当前轮次-1已结束的轮次
"小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币"
);
}
Db::commit();
return [
'code' => 1,
'msg' => '处理成功',
'data' => $result
];
} catch (Exception $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
/**
* 添加奖池流水
* @param int $pool_type 奖池类型1-小 2-大
* @param int $type 流水类型1-累计 2-开奖 3-划转 4-释放
* @param float $amount 金额
* @param float $before_amount 操作前金额
* @param float $after_amount 操作后金额
* @param int $relate_id 关联ID
* @param int $times 轮次
* @param string $remark 备注
*/
private function addPoolFlow($pool_type, $type, $amount, $before_amount, $after_amount, $relate_id, $times, $remark)
{
Db::name('bb_lottery_pool_flow_10')->insert([
'pool_type' => $pool_type,
'type' => $type,
'amount' => $amount,
'before_amount' => $before_amount,
'after_amount' => $after_amount,
'relate_id' => $relate_id,
'times' => $times, // 新增:写入轮次
'remark' => $remark,
'create_time' => time()
]);
}
/**
* 添加中奖记录
* @param int $uid 中奖用户ID
* @param int $prize_type 奖项类型1-小 2-大
* @param float $prize_amount 中奖金额
* @param float $pool_amount 奖池总金额
* @param int $ratio 中奖比例
* @param float $release_amount 释放金额
*/
private function addWinnerRecord($uid, $prize_type, $prize_amount, $pool_amount, $ratio, $release_amount)
{
Db::name('bb_lottery_winner_record')->insert([
'uid' => $uid,
'prize_type' => $prize_type,
'prize_amount' => $prize_amount,
'pool_amount' => $pool_amount,
'ratio' => $ratio,
'release_amount' => $release_amount,
'create_time' => time(),
'status' => 1 // 已发放
]);
// 此处可添加用户金币入账逻辑(如更新用户金币表)
}
/**
* 计算小奖中奖比例
* @param float $prize_amount 中奖金额
* @param float $pool_amount 奖池金额
* @return int 比例(%
*/
private function getSmallRatio($prize_amount, $pool_amount)
{
return intval(round($prize_amount / $pool_amount * 100));
}
/**
* 计算大奖中奖比例
* @param float $prize_amount 中奖金额
* @param float $pool_amount 奖池金额
* @return int 比例(%
*/
private function getBigRatio($prize_amount, $pool_amount)
{
return intval(round($prize_amount / $pool_amount * 100));
}
/**
* 统计中奖数据
* @param array $where 筛选条件如uid、prize_type、time
* @return array 统计结果
*/
public function statWinner($where = [])
{
$query = Db::name('bb_lottery_winner_record');
if (!empty($where['uid'])) {
$query->where('uid', $where['uid']);
}
if (!empty($where['prize_type'])) {
$query->where('prize_type', $where['prize_type']);
}
if (!empty($where['start_time']) && !empty($where['end_time'])) {
$query->whereBetween('create_time', [$where['start_time'], $where['end_time']]);
}
// 总中奖金额、总释放金额、中奖次数
$stat = $query->field([
'SUM(prize_amount) as total_prize',
'SUM(release_amount) as total_release',
'COUNT(id) as total_times'
])->find();
return [
'total_prize' => $stat['total_prize'] ?? 0,
'total_release' => $stat['total_release'] ?? 0,
'total_times' => $stat['total_times'] ?? 0
];
}
}

View File

@@ -0,0 +1,255 @@
<?php
namespace app\common\service;
use app\common\library\LotteryGiftLua;
use think\Cache;
use think\Db;
use think\Exception;
class LotteryService5
{
// Redis实例
private $redis;
// 配置参数
private $config;
private $bigPrizeWeights;
public function __construct()
{
$this->redis = Cache::store('redis')->handler();
// 加载配置
$this->config = Db::name('bb_lottery_config')->column('value', 'key');
// 初始化Redis缓存若Redis数据丢失从数据库恢复
$this->initRedisFromDb();
}
/**
* 缓存恢复:独立恢复大小轮次+对应金额
*/
private function initRedisFromDb()
{
// 1. 恢复奖池轮次取pool_type=1的最大times
$maxSmallRound = Db::name('bb_lottery_pool_flow_5')->where('pool_type', 1)->max('times') ?: 1;
if (!$this->redis->get('lottery:small_pool:round_5')) {
$this->redis->set('lottery:small_pool:round_5', $maxSmallRound);
}
// 2. 恢复奖池当前轮次的次数/金额
$small_round = intval($this->redis->get('lottery:small_pool:round_5'));
if (!$this->redis->get('lottery:small_pool:total_times_5')) {
$smallTotalTimes = Db::name('bb_lottery_pool_flow_5')
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
->count();
$this->redis->set('lottery:small_pool:total_times_5', $smallTotalTimes);
}
if (!$this->redis->get('lottery:small_pool:total_gold_5')) {
$smallTotalGold = Db::name('bb_lottery_pool_flow_5')
->where(['pool_type' => 1, 'type' => 1, 'times' => $small_round])
->sum('amount') ?: 0;
$this->redis->set('lottery:small_pool:total_gold_5', $smallTotalGold);
}
}
/**
* 处理送礼抽奖逻辑
* @param int $send_uid 送礼用户ID
* @param float $gift_gold 礼物金币数
* @param int $giftId 礼物ID
* @return array 处理结果
* @throws Exception
*/
public function handleGift($send_uid, $gift_gold, $giftId)
{
// 参数校验
if ($gift_gold <= 0 || !$send_uid) {
throw new Exception('参数错误');
}
// 读取配置+独立轮次
$small_trigger_times = intval($this->config['small_pool_trigger_times_5'] ?? 200);//触发抽奖次数
$small_round = intval($this->redis->get('lottery:small_pool:round_5') ?: 1);//轮次
$lucky_rate = intval($this->config['lucky_rate'] ?? 1);//收益率
$lottery_rate = intval($this->config['lottery_rate_5'] ?? 100);//爆币率
if($lottery_rate <= 2){
throw new Exception('配置错误');
}
// 加载Lua脚本
$luaSha = LotteryGiftLua::getLotteryLuaScript5();
// 执行Lua脚本入参small_round + big_round
$result = $this->redis->eval($luaSha, [
$send_uid,
$gift_gold,
$small_trigger_times,
$small_round,
$lucky_rate,
$lottery_rate
], 0);
$result = json_decode($result, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception('Lua脚本执行失败');
}
// 开启数据库事务
Db::startTrans();
try {
// . 1记录小奖池累计流水未开奖时
if ($result['is_small_prize'] == 0) {
$this->addPoolFlow(
1, // 中级奖池
1, // 累计
$result['small_pool_add'],
$result['small_total_gold'] - $result['small_pool_add'],
$result['small_total_gold'],
$giftId,
$result['small_round'], // 新增:传入轮次
"小奖池累计:用户{$send_uid}送礼,轮次{$result['small_round']}"
);
} else {
$winnerUid = $send_uid; // 奖默认给当前送礼用户
//中奖金额
$prizeAmount = floor($result['small_prize_amount'] / $gift_gold) * $gift_gold;
// 小奖中奖记录
$this->addWinnerRecord(
$winnerUid,
3, // 中级奖
$prizeAmount,//中奖金额
$result['small_total_gold'],//奖池总金额
$this->getSmallRatio($result['small_prize_amount'], $result['small_total_gold']),//中奖比例
$result['small_total_gold'] - $prizeAmount //释放金额
);
// 3. 小奖池开奖流水
$this->addPoolFlow(
1, //
4, //
$prizeAmount,
$result['small_total_gold'],
$result['small_total_gold'] - $prizeAmount,
$giftId,
$result['small_round'] - 1, // 开奖轮次为当前轮次-1已结束的轮次
"小奖池开奖:轮次" . ($result['small_round'] - 1).",中奖金额:{$result['small_prize_amount']}金币"
);
}
Db::commit();
return [
'code' => 1,
'msg' => '处理成功',
'data' => $result
];
} catch (Exception $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
/**
* 添加奖池流水
* @param int $pool_type 奖池类型1-小 2-大
* @param int $type 流水类型1-累计 2-开奖 3-划转 4-释放
* @param float $amount 金额
* @param float $before_amount 操作前金额
* @param float $after_amount 操作后金额
* @param int $relate_id 关联ID
* @param int $times 轮次
* @param string $remark 备注
*/
private function addPoolFlow($pool_type, $type, $amount, $before_amount, $after_amount, $relate_id, $times, $remark)
{
Db::name('bb_lottery_pool_flow_5')->insert([
'pool_type' => $pool_type,
'type' => $type,
'amount' => $amount,
'before_amount' => $before_amount,
'after_amount' => $after_amount,
'relate_id' => $relate_id,
'times' => $times, // 新增:写入轮次
'remark' => $remark,
'create_time' => time()
]);
}
/**
* 添加中奖记录
* @param int $uid 中奖用户ID
* @param int $prize_type 奖项类型1-小 2-大
* @param float $prize_amount 中奖金额
* @param float $pool_amount 奖池总金额
* @param int $ratio 中奖比例
* @param float $release_amount 释放金额
*/
private function addWinnerRecord($uid, $prize_type, $prize_amount, $pool_amount, $ratio, $release_amount)
{
Db::name('bb_lottery_winner_record')->insert([
'uid' => $uid,
'prize_type' => $prize_type,
'prize_amount' => $prize_amount,
'pool_amount' => $pool_amount,
'ratio' => $ratio,
'release_amount' => $release_amount,
'create_time' => time(),
'status' => 1 // 已发放
]);
// 此处可添加用户金币入账逻辑(如更新用户金币表)
}
/**
* 计算小奖中奖比例
* @param float $prize_amount 中奖金额
* @param float $pool_amount 奖池金额
* @return int 比例(%
*/
private function getSmallRatio($prize_amount, $pool_amount)
{
return intval(round($prize_amount / $pool_amount * 100));
}
/**
* 计算大奖中奖比例
* @param float $prize_amount 中奖金额
* @param float $pool_amount 奖池金额
* @return int 比例(%
*/
private function getBigRatio($prize_amount, $pool_amount)
{
return intval(round($prize_amount / $pool_amount * 100));
}
/**
* 统计中奖数据
* @param array $where 筛选条件如uid、prize_type、time
* @return array 统计结果
*/
public function statWinner($where = [])
{
$query = Db::name('bb_lottery_winner_record');
if (!empty($where['uid'])) {
$query->where('uid', $where['uid']);
}
if (!empty($where['prize_type'])) {
$query->where('prize_type', $where['prize_type']);
}
if (!empty($where['start_time']) && !empty($where['end_time'])) {
$query->whereBetween('create_time', [$where['start_time'], $where['end_time']]);
}
// 总中奖金额、总释放金额、中奖次数
$stat = $query->field([
'SUM(prize_amount) as total_prize',
'SUM(release_amount) as total_release',
'COUNT(id) as total_times'
])->find();
return [
'total_prize' => $stat['total_prize'] ?? 0,
'total_release' => $stat['total_release'] ?? 0,
'total_times' => $stat['total_times'] ?? 0
];
}
}

View File

@@ -139,27 +139,28 @@ class RedpacketService
$recordModel->save($recordData);
// 更新用户钱包
$coinField = $redpacket['coin_type'] == 1 ? 'coin' : 'earnings';
//增加余额
$addres = Db::name('user_wallet')
->where('user_id', $userId)
->inc($coinField, $amount)
->update();
//记录用户金币日志
$data = [
'user_id' => $userId,
'change_value' => $amount,
'room_id' => $redpacket['room_id'],
'money_type' => $redpacket['coin_type'],
//记录日志 32-发红包金币29-发红包钻石30-抢红包金币31-抢红包(钻石)
'change_type' => $redpacket['coin_type'] == 1 ? 30 : 31,
'from_id' => $redpacket['room_id'],
'remarks' => '抢红包收入',
'createtime' => time()
];
// $coinField = $redpacket['coin_type'] == 1 ? 'coin' : 'earnings';
// //增加余额
// $addres = Db::name('user_wallet')
// ->where('user_id', $userId)
// ->inc($coinField, $amount)
// ->update();
// //记录用户金币日志
// $data = [
// 'user_id' => $userId,
// 'change_value' => $amount,
// 'room_id' => $redpacket['room_id'],
// 'money_type' => $redpacket['coin_type'],
// //记录日志 32-发红包金币29-发红包钻石30-抢红包金币31-抢红包(钻石)
// 'change_type' => $redpacket['coin_type'] == 1 ? 30 : 31,
// 'from_id' => $redpacket['room_id'],
// 'remarks' => '抢红包收入',
// 'createtime' => time()
// ];
$res = Db::name('vs_user_money_log')->insert($data);
if(!$res || !$addres){
// $res = Db::name('vs_user_money_log')->insert($data);
$res = model('api/UserWallet')->change_user_cion_log($userId,$amount,$redpacket['room_id'],30,'30-抢红包(金币');
if(!$res){
Db::rollback();
}
@@ -186,6 +187,15 @@ class RedpacketService
unset($grabResult['all_records']);//前端不要
unset($grabResult['statistics']);//前端不要
//处理任务
//查询今日是否抢到5个红包
$tady_red_num = Db::name('redpacket_record')
->where('user_id',$userId)
->where('createtime', '>=', strtotime(date('Y-m-d')))
->count();
if($tady_red_num <= 5){
model('api/Tasks')->tasks_complete($userId,36);
}
return [
'code' => 1,
'msg' => '抢红包成功',

View File

@@ -15,9 +15,7 @@ class DaySeconds
*/
function index()
{
echo "清除房间热度值:\n";
$this->clear_room_today_hot_value();//0点以后房间热度值清零
echo "\n";
echo "系统降身价:\n";
$this->system_downgrade();
@@ -35,26 +33,26 @@ class DaySeconds
/*
* 0点以后房间热度值清零
* 配置:定时脚本每天 0点 执行
* 配置:
*/
public function clear_room_today_hot_value() {
$where = [];
$where['delete_time'] = 0;
$where['is_show_room'] = 1;
$room = db::name('vs_room')->where($where)->select();
echo date('Y-m-d H:i:s').' 开始清零:'.count($room)."\n";
foreach ($room as $key => $value) {
$data = [
'today_hot_value' => 0,
];
db::name('vs_room')->where(['id' => $value['id']])->update($data);
}
echo date('Y-m-d H:i:s').' 完成'."\n";
}
// /*
// * 0点以后房间热度值清零
// * 配置:定时脚本每天 0点 执行
// * 配置:
// */
// public function clear_room_today_hot_value() {
// $where = [];
// $where['delete_time'] = 0;
// $where['is_show_room'] = 1;
// $room = db::name('vs_room')->where($where)->select();
// echo date('Y-m-d H:i:s').' 开始清零:'.count($room)."\n";
// foreach ($room as $key => $value) {
// $data = [
// 'today_hot_value' => 0,
// ];
// db::name('vs_room')->where(['id' => $value['id']])->update($data);
// }
// echo date('Y-m-d H:i:s').' 完成'."\n";
//
// }
//系统降身价
public function system_downgrade(){

View File

@@ -4,6 +4,7 @@ namespace app\cron\controller;
use app\common\model\Redpacket;
use app\common\model\UserWallet;
use app\common\controller\Push;
use think\Cache;
use think\Db;
use Yzh\YunPay;
@@ -51,10 +52,14 @@ class PerformPerSecond
$this->sign_room_time_end();
echo "\n";
echo "酒吧房间时间结束处理:\n";
echo "酒吧房间麦位时间结束处理:\n";
$this->bar_room_time_end();
echo "\n";
echo "炼仙传说监控:\n";
$this->create_monster_log();
echo "\n";
}
@@ -158,7 +163,7 @@ class PerformPerSecond
continue;
}
}
if(in_array($value['yun_order_status'],[261,5077,255])){
if(in_array($value['yun_order_status'],[261,5077,255,254,6050])){
continue;
}
echo "提现订单查询:".$value['order_sn']."\n";
@@ -198,7 +203,7 @@ class PerformPerSecond
'received_tax_amount' => $result['data']['received_tax_amount'] ?? 0,
]);
// if(in_array($result['data']['code'],[5077,261]) && $value['yun_order_status'] == null){
if(in_array($result['data']['code'],[5077,261,255]) && !in_array($value['yun_order_status'],[5077,261,255])){
if(in_array($result['data']['code'],[5077,261,255,254,6050]) && !in_array($value['yun_order_status'],[5077,261,255,254,6050])){
// if($result['data']['code']==5077 && $value['yun_order_status'] == null){
//该支付宝账户不存在或未开通手机号转账功能。如有疑问,请收款用户联系支付宝客服咨询。
//退还金币
@@ -297,7 +302,7 @@ class PerformPerSecond
->where('end_time', '<', $now)
->where('left_count', '>', 0)
->select();
$processedCounts = 0;
foreach ($expiredRedpackets as $redpacket) {
Db::startTrans();
try {
@@ -305,52 +310,44 @@ class PerformPerSecond
if ($redpacket['left_amount'] > 0) {
// 更新用户钱包
$coinField = $redpacket['coin_type'] == 1 ? 'coin' : 'earnings';
//增加余额
$addres = Db::name('user_wallet')
->where('user_id', $redpacket['user_id'])
->inc($coinField, $redpacket['left_amount'])
->update();
//记录用户金币日志
$data = [
'user_id' => $redpacket['user_id'],
'change_value' => $redpacket['left_amount'],
'room_id' => $redpacket['room_id'],
'money_type' => $redpacket['coin_type'],
//记录日志 32-发红包金币29-发红包钻石30-抢红包金币31-抢红包钻石33-红包剩余退回金币34-红包剩余退回(钻石)
'change_type' => $redpacket['coin_type'] == 1 ? 33 : 34,
'from_id' => $redpacket['room_id'],
'remarks' => '红包剩余退回',
'createtime' => time()
];
$res = Db::name('vs_user_money_log')->insert($data);
if(!$res || !$addres){
Db::rollback();
if($coinField == 'coin'){
// //增加户金币并记录日志
$wallet_update = model('api/UserWallet')->change_user_cion_log($redpacket['user_id'],$redpacket['left_amount'],$redpacket['room_id'],33,'红包剩余退回');
if(!$wallet_update){
Db::rollback();
}
}else{
//增加收益并记录日志
$receiver = model('api/UserWallet')->change_user_earnings_log($redpacket['user_id'],$redpacket['left_amount'],$redpacket['room_id'],34,'红包剩余退回');
if(!$receiver){
Db::rollback();
}
}
}
// 更新红包状态为已结束
// 更新红包状态为已退款
Db::name('redpacket')
->where('id', $redpacket['id'])
->update([
'status' => Redpacket::STATUS_FINISHED,
'status' => Redpacket::STATUS_REFUNDED,
'updatetime' => $now
]);
// 更新Redis缓存
// 清理Redis缓存
$redis = Cache::store('redis')->handler();
$redisKey = "redpacket:{$redpacket['id']}";
$redis->hSet($redisKey, 'status', Redpacket::STATUS_FINISHED);
$redis->del($redisKey);
Db::commit();
$processedCount++;
$processedCounts++;
} catch (\Exception $e) {
Db::rollback();
// 记录日志
\think\Log::error("红包退款失败: {$redpacket['id']}, 错误: " . $e->getMessage());
}
}
echo "处理过期红包-共". $processedCount . "条数据\n";
echo "处理过期红包-共". $processedCounts . "条数据\n";
echo "处理未开始红包-共". $processedCount . "条数据\n";
}
//签约房时间结束处理和签约到期处理
@@ -382,7 +379,7 @@ class PerformPerSecond
}
}
//酒吧房间时间结束处理
//酒吧房间麦位时间结束处理
public function bar_room_time_end(){
$bar_pit_gift = Db::name('vs_room_pit')->where(['end_time'=>['<',time()]])->where(['end_time'=>['<>',0]])->select();
if($bar_pit_gift){
@@ -398,4 +395,17 @@ class PerformPerSecond
}
echo "酒吧房间时间结束处理完成\n";
}
//监控练仙传说
public function create_monster_log(){
$key_name = "admin:cli:create_monster_log";
redis_lock_exit($key_name,1,1);
$reslut = model('api/Monster')->create_monster_log();
redis_unlock($key_name);
if($reslut['code'] == 0){
echo date('Y-m-d H:i:s') . "监控练仙传说 执行失败" . $reslut['msg'] . "\r\n";
}else{
echo date('Y-m-d H:i:s') . "监控练仙传说 执行成功" . $reslut['data'] . "\r\n";
}
}
}

View File

@@ -13,9 +13,9 @@ class RoomHourRanking
*/
function index()
{
echo "小时榜 开始发礼物:\n";
// echo "小时榜 开始发礼物:\n";
// $this->send_gift();//小时榜 送礼物
echo "发礼物结束 \n";
// echo "发礼物结束 \n";
echo "清除房间离线超1小时的用户\n";
$this->clear_room_offline_user();
@@ -30,6 +30,11 @@ class RoomHourRanking
$this->sign_notice();
echo "\n";
echo "清除房间热度值:\n";
$this->clear_room_today_hot_value();//整点以后房间热度值清零
echo "\n";
}
@@ -182,30 +187,34 @@ class RoomHourRanking
//添加金币到钱包
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()
];
// $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();
// }
//开启事务
Db::startTrans();
$res = Db::name('vs_user_money_log')->insert($data);
$res = model('api/UserWallet')->change_user_cion_log($user_id,$coin,0,27,'小时榜获得');
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;
@@ -474,4 +483,23 @@ class RoomHourRanking
echo "通知签约上级徒弟48小时后到期结束 共发送". $user_sign_sed_count . "条数据"."\n";
}
/*
* 整点以后房间热度值清零
* 配置:
*/
public function clear_room_today_hot_value() {
$room = db::name('vs_room')->where(['room_status' => 1,'today_hot_value' => ['>',0]])->select();
echo date('Y-m-d H:i:s').' 开始清零:'.count($room)."\n";
foreach ($room as $key => $value) {
$data = [
'today_hot_value' => 0,
];
db::name('vs_room')->where(['id' => $value['id']])->update($data);
}
echo date('Y-m-d H:i:s').' 完成'."\n";
}
}

View File

@@ -16,20 +16,72 @@ class TenSeconds
function index()
{
//下面两个经业务调整 暂时不要了
// echo "房间在线人数:\n";
// $this->auction_end_notice();//拍卖房结束提醒
// echo "\n";
//清理切后台超过5分钟的用户
// echo "清理切后台超过5分钟的用户\n";
// $this->clear_offline_user();
// echo "\n";
//房间营业时间结束后把用户踢出房间
// echo "房间营业时间结束后把用户踢出房间\n";
// $this->room_end_kick_user();
// echo "\n";
// echo "清除房间热度值:\n";
// $this->clear_room_today_hot_value();//整点以后房间热度值清零
// echo "\n";
}
//在线人数
//房间营业时间结束后把用户踢出房间
public function room_end_kick_user()
{
//查找房间有人的用户
$room_user_list = Db::name('vs_room_visitor')->group('room_id')->select();
if($room_user_list){
foreach ($room_user_list as $room_user){
//查找房间营业时间
$room_info = Db::name('vs_room')->where('id',$room_user['room_id'])->find();
//房间是否在营业时间
$startTime = $room_info['start_time'];
$endTime = $room_info['end_time'];
//查看现在时间是否在营业时间
$isBusinessHours = model('api/Room')-> isBetweenTime($startTime, $endTime);
//当前时间不在营业时间内
if (!$isBusinessHours) {
$user_list = Db::name('vs_room_visitor')->where('room_id',$room_user['room_id'])->select();
if($user_list){
foreach ($user_list as $user){
model('Room')->quit_room($room_info['user_id'], $room_user['room_id'],$user['user_id'],1);
}
}
}
echo "房间:".$room_user['room_id']."营业时间结束,把用户踢出房间\n";
}
}
}
/*
* 整点以后房间热度值清零
* 配置:
*/
public function clear_room_today_hot_value() {
$room = db::name('vs_room')->where(['room_status' => 1,'today_hot_value' => ['>',0]])->select();
echo date('Y-m-d H:i:s').' 开始清零:'.count($room)."\n";
foreach ($room as $key => $value) {
$data = [
'today_hot_value' => 0,
];
db::name('vs_room')->where(['id' => $value['id']])->update($data);
}
echo date('Y-m-d H:i:s').' 完成'."\n";
}
}

View File

@@ -31,8 +31,10 @@ class Test
// $this->giftSend();
// $this->createGuildSubsidyDataNewNew();
// $this->task_coin_count();
$this->createGuildSubsidyDataNew();
// $this->createGuildSubsidyDataNew();
// $this->repair_guild_room_data();
// $this->check_guild_room_data();
// $this->merge_guild();
}
@@ -1066,4 +1068,110 @@ class Test
}
echo "修改完成 共:".$num;
}
//数据校验
//查询公会房间异常数据
public function check_guild_room_data(){
echo "开始查询\n";
$guild_user_data = db::name('vs_guild_user')->where(['apply_time'=>['>',0],'status'=>1,'quit_type'=>0])->field('id,user_id,room_id,guild_id,apply_time,quit_time,createtime')->select();
foreach ($guild_user_data as $k => $v) {
$room_info = db::name('vs_room')->where(['user_id'=>$v['user_id'],'delete_time'=>0,'type_id'=>['<>',6],'apply_status'=>1])->field('id,room_name,room_number,type_id,createtime')->find();
if($room_info){
if($room_info['id']!=$v['room_id']) {
//公会名称
$guild_name = db::name('vs_guild')->where('id',$v['guild_id'])->value('guild_name');
echo "公会名称:".$guild_name;
echo " 公会Id".$v['guild_id']." 关系Id".$v['id']."错误房间Id".$v['room_id']."正确房间Id".$room_info['id'];
echo " 房间:".$room_info['room_name']."--".$room_info['room_number'];
echo "\n";
echo " 申请加入公会时间:".date('Y-m-d H:i:s',$v['createtime']);
echo "\n";
echo " 创建房间时间:".date('Y-m-d H:i:s',$room_info['createtime']);
echo "\n";
echo " 加入公会审核通过:".date('Y-m-d H:i:s',$v['apply_time']);
echo "\n";
}
}
}
echo "完成";
}
public function merge_guild(){die("暂停");
$guild_id = 10029; // 要合并的
$merge_guild_id = 10005; //并入的
//解散工会
$guild = model('adminapi/Guild')->getOne(['guild_special_id'=>$guild_id]);
$merge_guild=model('adminapi/Guild')->getOne(['guild_special_id'=>$merge_guild_id]);
// if(empty($guild)){
// echo "该工会不存在";
// }
// if($guild['status'] == 2){
// echo "该工会已解散";
// }
// if(!$merge_guild_id){
// echo "请选择并入工会";
// }
// if(empty($merge_guild)){
// echo "并入工会不存在";
// }
$guild_id = $guild['id'];
$merge_guild_id = $merge_guild['id'];
// db::startTrans();
// try{
// $res = model('adminapi/Guild')->edit(['id'=>$guild_id],['status'=>2,'delete_time'=>time()]);
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>3,'status'=>1])->select();
$use_num = 0;
echo "公会名称:".$guild['guild_name']." 公会Id".$guild_id." 公会人数:".count($merge_guild_user)." 合并公会名称:".$merge_guild['guild_name']." 合并公会Id".$merge_guild_id."\n";
foreach ($merge_guild_user as $key=>$value){
// $res = db('vs_guild_user')->insert([
// 'user_id'=>$value['user_id'],
// 'guild_id'=>$merge_guild_id,
// 'room_id'=>$value['room_id'],
// 'status'=>$value['status'],
// 'is_show_room'=>$value['is_show_room'],
// 'remarks'=>"公会合并:从".$guild['guild_name']."合入".$merge_guild['guild_name'],
// 'settlement_ratio' =>$value['settlement_ratio'],
// 'apply_time'=>time(),
// 'createtime'=>time(),
// ]);
// if(!$res){
// db::rollback();
// return V(0,"失败");
// }
//更新公会人数
// db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
//拉用户进入工会群聊
if($merge_guild_id<=95){
$merge_guild_id = "g".$merge_guild_id;
}else{
$merge_guild_id = $merge_guild_id;
}
$rid = 'g'.$merge_guild_id;
// $reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
// if($reslut['code']==1){
// echo "用户:".$value['user_id']."加入群聊:".$rid;
// $use_num ++;
// }
echo 'u'.$value['user_id']."\n";
}
echo " 成功:".$use_num."\n";
// $return = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>0])->update(['quit_type'=>3,'quit_time'=>time(),'updatetime'=>time(),'delete_time'=>time()]);
// if (!$return) {
// db::rollback();
// return V(0,"失败");
// }
// //解散群
// if($guild_id<=95){
// $guild_id = "g".$guild_id;
// }else{
// $guild_id = $guild_id;
// }
// model('api/Tencent')->delete_group('g'.$guild_id);
// db::commit();
// return V(1,"成功");
// } catch(\Exception $e) {
// db::rollback();
// return V(0,$e->getMessage());
// }
}
}

View File

@@ -87,23 +87,20 @@ class Index extends GuildAdmin
->where(['createtime'=>['>',$stime_input]])
->sum('total_price');
//礼物总分成
$return_data['gift_money'] = db::name('vs_user_money_log')->where([
$return_data['gift_money'] = db::name('user_earnings_log')->where([
'room_id'=>['in',$rooms],
'money_type'=>2,
'change_type'=>11,
'createtime'=>['<',$etime]
])->where(['createtime'=>['>',$stime_input]])->sum('change_value');
//主持分成
$return_data['host_money'] = db::name('vs_user_money_log')->where([
$return_data['host_money'] = db::name('user_earnings_log')->where([
'room_id'=>['in',$rooms],
'money_type'=>2,
'change_type'=>19,
'createtime'=>['<',$etime]
])->where(['createtime'=>['>',$stime_input]])->sum('change_value');
//房主分成
$return_data['room_owner_money'] = db::name('vs_user_money_log')->where([
$return_data['room_owner_money'] = db::name('user_earnings_log')->where([
'room_id'=>['in',$rooms],
'money_type'=>2,
'change_type'=>18,
'createtime'=>['<',$etime]
])->where(['createtime'=>['>',$stime_input]])->sum('change_value');

View File

@@ -1,5 +1,7 @@
<?php
use addons\epay\library\Service;
use think\Log;
class WxPay
{
@@ -475,4 +477,97 @@ class WxPay
}
return $output;
}
/**
* 获取支付参数 (统一下单)
* @ApiMethod (POST)
* @ApiRoute (/api/pay/create)
*/
public function WxPayMp($d)
{
$total_fee = abs(floatval($d['money'])) * 100;// 微信支付 单位为分
// 1. 接收参数
$order_no = $d['order_sn'];
$amount = $total_fee;
$openid = $d['openid'];
$pay_type = 'wechat'; // wechat 或 alipay
if (!$order_no || !$amount || !$openid) {
$this->error('参数不完整');
}
// 3. 生成支付参数
try {
$params = [
'amount' => sprintf('%.2f', $amount), // 单位:元
'orderid' => $order_no,
'type' => $pay_type,
'title' => '商品支付-' . $order_no,
'notifyurl' => url('/api/pay/notify', '', true, true), // 异步通知
'returnurl' => url('/index/index', '', true, true), // 支付后跳转
'method' => 'mp', // mp=公众号支付, miniapp=小程序支付
'openid' => $openid, // 必须
];
// 4. 调用 epay 插件统一下单
$result = Service::submitOrder($params);
// 5. 返回前端所需参数
$this->success('成功', [
'order_no' => $order_no,
'pay_params' => $result, // 插件返回的支付参数
'timestamp' => time(),
]);
} catch (\Exception $e) {
Log::error('支付下单失败: ' . $e->getMessage());
$this->error('支付创建失败: ' . $e->getMessage());
}
}
/**
* 微信支付Jsapa
* @param string $data 业务参数 body out_trade_no total_fee
* @param string $data ['out_trade_no'] 订单号 必填
* @param string $data ['total_fee'] 订单金额 必填
* @param string $data ['body'] 订单详情 必填
* @return $response 返回app所需字符串
*/
public function WxPayJsapi($d) {
$total_fee = abs(floatval($d['money'])) * 100;// 微信支付 单位为分
$ip = $this->get_client_ip();
if ($ip == '::1')
$ip = '1.1.1.1';
$data ["appid"] = \think\Env::get('wechatpay.appid');
$data ["mch_id"] = \think\Env::get('wechatpay.mch_id');
$data ["nonce_str"] = $this->getRandChar(32);
$data ["body"] = $d['remarke'];
$data ["out_trade_no"] = $d['order_sn'];
$data ["total_fee"] = $total_fee;
$data ["spbill_create_ip"] = $ip;
$data ["notify_url"] = get_system_config_value("web_site")."/api/Payment/notify_wx";
$data ["trade_type"] = "JSAPI";
$data ["openid"] = $d['openid'];// 必须
$s = $this->getSign($data);
$data ["sign"] = $s;
$xml = $this->arrayToXml($data);
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
$response = $this->postXmlCurl($xml, $url);
$re = $this->xmlstr_to_array($response);
if ($re ['return_code'] == 'FAIL') {
return array(-1, '订单创建失败!'.\think\Env::get('wechatpay.api_v3_key'), $re['return_msg']);
}
// 二次签名
$reapp = $this->getOrder($re['prepay_id']);
return $reapp;
}
}