# 功能描述:
游戏中,某道具活动期间价格为10元,活动结束后,价格恢复为20元,但后台程序虽然恢复了20元的价格,但前台显示任然为10元,导致玩家在游戏中闹!
解决办法是,恢复这期间够卖了该道具的玩家的金额!
# 首先,需要测试功能是否正确:
1.导入正式环境下的数据库(或直接导入VipNotes表即可)
2.将正式环境下的数据导入本地数据库测试.
# 创建视图,返还用户充值:
1.根据范围创建视图:
CREATE VIEW PayBack(playerID,sumSpend) as SELECT playerID,SUM(spend) FROM VipNotes WHERE id > 291209 and id < 291396 and vipType = 1446 GROUP BY playerID;
2.查看数据格式是否正确:
SELECT * FROM PayBack;
+----------+----------+
| playerID | sumSpend |
+----------+----------+
| 6 | 10 |
| 15 | 10 |
| 47 | 10 |
| 104 | 510 |
| 136 | 100 |
| 286 | 70 |
| 319 | 260 |
| 633 | 20 |
| 1080 | 10 |
| 1315 | 10 |
| 2027 | 90 |
| 2600 | 20 |
| 4034 | 40 |
| 5620 | 410 |
| 8404 | 70 |
+----------+----------+
3.查看还原前玩家的金钱:
SELECT id,playerName,money from Player,PayBack where id = PayBack.playerID;
+------+--------------+-------+
| id | playerName | money |
+------+--------------+-------+
| 6 | 零壹* | 665 |
| 15 | 左* | 685 |
| 47 | 瑶* | 2648 |
| 104 | 杀式* | 845 |
| 136 | 紫* | 25 |
| 286 | 痞子* | 10 |
| 319 | 雨天* | 23 |
| 633 | 天矢* | 5 |
| 1080 | 陆* | 433 |
| 1315 | 指* | 60 |
| 2027 | 星* | 10 |
| 2600 | 你* | 175 |
| 4034 | 兄弟* | 19 |
| 5620 | 晖* | 7 |
| 8404 | 曾宪* | 14 |
+------+--------------+-------+
4.恢复玩家金钱:
UPDATE Player player JOIN PayBack payBack SET player.money = player.money + payBack.sumSpend WHERE player.id = payBack.playerID;
5.查看还原后玩家的金钱:
SELECT id,playerName,money from Player,PayBack where id = PayBack.playerID;
+------+--------------+-------+
| id | playerName | money |
+------+--------------+-------+
| 6 | 零壹* | 675 |
| 15 | 左* | 695 |
| 47 | 瑶* | 2658 |
| 104 | 杀式* | 1355 |
| 136 | 紫* | 125 |
| 286 | 痞子* | 80 |
| 319 | 雨天* | 283 |
| 633 | 天矢* | 25 |
| 1080 | 陆* | 443 |
| 1315 | 指* | 70 |
| 2027 | 星* | 100 |
| 2600 | 你* | 195 |
| 4034 | 兄* | 59 |
| 5620 | 晖* | 417 |
| 8404 | 曾宪* | 84 |
+------+--------------+-------+
6.删除无用视图:
DROP VIEW PayBack;