1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * AppController.php UTF-8
- * 游戏入口
- *
- * @date : 2017/11/15 17:21
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace box\api\controller;
- use box\common\controller\V2ApiBaseController;
- use huo\controller\integral\MemIa;
- use huo\controller\member\MemCache;
- use huo\model\game\GamecategoryModel;
- use huo\model\member\MemGameModel;
- use huolib\constant\CacheConst;
- use huolib\constant\CategoryConst;
- use huolib\constant\IaConst;
- use huolib\constant\MemConst;
- use huolib\status\CommonStatus;
- use huolib\tool\RateLimit;
- use huomp\controller\member\MemberOut;
- use think\Cache;
- class AppController extends V2ApiBaseController {
- public function _initialize() {
- parent::_initialize();
- $this->checkLogin();
- $_rs = (new RateLimit())->rateLimit($this->mem_id);
- if (false == $_rs) {
- $_code = CommonStatus::TOO_MANY_REQUESTS;
- $this->error(CommonStatus::getMsg($_code));
- }
- }
- /**
- * 打开游戏开始计算时长
- * http://doc.1tsdk.com/159?page_id=4820
- * 【域名】/game/start
- */
- public function gameOpen() {
- $_game_rq = $this->setGameData();
- $_app_id = $_game_rq->getHAppId();
- $_game_id = $this->request->param('game_id/d', 0);
- /* 判断是否为红包任务列表游戏 */
- $_rs = (new GamecategoryModel())->isGameExist(CategoryConst::CATE_CATE_RP, $_game_id);
- if ($_rs == false) {
- $_cache_key = CacheConst::CACHE_MEM_OPEN_GAME_PREFIX.md5(json_encode(array($this->mem_id, $_game_id)));
- $_rdata = ['status' => MemConst::OPEN_GAME_STATUS_2];
- Cache::set($_cache_key, $_rdata);
- $this->success(lang('SUCCESS'), $_rdata);
- }
- $_rs = (new MemberOut())->doOpenGame($this->mem_id, $_app_id, $_game_id);
- if (false === $_rs) {
- $this->error(lang('ERROR'));
- }
- $_rdata = ['status' => $_rs];
- $this->success(lang('SUCCESS'), $_rdata);
- }
- /**
- * 打开游戏--领取奖励
- * http://doc.huosdk.com/159?page_id=4507
- * 【域名】/game/open
- */
- public function startup() {
- $_game_rq = $this->setGameData();
- $_game_id = $this->request->param('game_id/d', 0);
- $_app_id = $_game_rq->getHAppId();
- $_mem_data = MemCache::ins()->getInfoById($this->mem_id);
- /* 试玩任务处理 */
- (new MemberOut())->setRpGamePlayCnt($this->mem_id, $_game_id);
- (new MemGameModel())->login($_mem_data, $this->mem_id, $_game_id);
- $_ext = [
- 'app_id' => $_app_id,
- 'game_id' => $_game_id,
- ];
- /* 打开小游戏获取收益 */
- (new MemIa($this->mem_id))->doItgAct(IaConst::IA_OPEN_GAME, $_ext);
- $_cache_key = CacheConst::CACHE_MEM_OPEN_GAME_PREFIX.md5(json_encode(array($this->mem_id, $_game_id)));
- $_status = Cache::get($_cache_key);
- $_status = json_decode($_status, true);
- $this->success(lang('SUCCESS'), $_status);
- }
- }
|