diff --git a/doc/Mission.py b/doc/Mission.py index a9e11c99..15c3e527 100644 --- a/doc/Mission.py +++ b/doc/Mission.py @@ -1,137 +1,161 @@ -# -*- coding: utf-8 -*- - -import _common - -class Mission(object): - - def __init__(self): - self.apis = [ - { - 'name': 'missionList', - 'desc': '获取任务列表', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=missionList', - 'params': [ - _common.ReqHead(), - ['type', 0, '任务类型(!!!注意这里的类型和任务表里的任务不是一回事) 1:每日任务 2:赛季周任务 3:悬赏任务'], - ], - 'response': [ - _common.RspHead(), - ['current_day_active_value', 0, '当前日活跃度'], - ['current_week_active_value', 0, '当前周活跃度'], - ['day_active_limit', 0, '每日活跃度上限'], - ['week_active_limit', 0, '每周活跃度上限'], - ['day_time_end', 0, '每日活动结算时间'], - ['week_time_end', 0, '每周活动结算时间'], - ['!mission_list1', [_common.Mission()], '任务列表1'], - ['!mission_list2', [_common.Mission()], '任务列表2'], - ] - }, - { - 'name': 'sendOfferRewardMission', - 'desc': '派遣悬赏任务', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=sendOfferRewardMission', - 'params': [ - _common.ReqHead(), - ['mission_id', 0, '任务id'], - ['objects', '', '悬赏任务对象列表type:id|'] - ], - 'response': [ - _common.RspHead(), - ['award', _common.Award(), '奖励信息'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ['mission_chg', _common.Mission(), '任务的最新信息(可能为null客户端需要做容错处理)'], - ] - }, - { - 'name': 'cancelOfferRewardMission', - 'desc': '撤销派遣悬赏任务', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=cancelOfferRewardMission', - 'params': [ - _common.ReqHead(), - ['mission_id', 0, '任务id'], - ], - 'response': [ - _common.RspHead(), - ['award', _common.Award(), '奖励信息'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - { - 'name': 'boostOfferRewardMissionPreview', - 'desc': '加速悬赏任务', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=boostOfferRewardMissionPreview', - 'params': [ - _common.ReqHead(), - ['mission_id', 0, '任务id'], - ], - 'response': [ - _common.RspHead(), - ['boost_chg', 0, '加速所需ceg'], - ] - },{ - 'name': 'boostOfferRewardMission', - 'desc': '加速悬赏任务', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=boostOfferRewardMission', - 'params': [ - _common.ReqHead(), - ['mission_id', 0, '任务id'], - ], - 'response': [ - _common.RspHead(), - ['award', _common.Award(), '奖励信息'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ['mission_chg', _common.Mission(), '任务的最新信息(可能为null客户端需要做容错处理)'], - ] - }, - { - 'name': 'offerRewardMissionPreview', - 'desc': '悬赏任务奖励预览', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=boostOfferRewardMission', - 'params': [ - _common.ReqHead(), - ['mission_id', 0, '任务id'], - ['objects', '', '悬赏任务对象列表type:id|'] - ], - 'response': [ - _common.RspHead(), - ['!data', _common.AwardItem(), '奖励信息'], - ] - }, - { - 'name': 'commitMission', - 'desc': '提交任务(领取奖励)', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=commitMission', - 'params': [ - _common.ReqHead(), - ['mission_id', 0, '任务id'], - ], - 'response': [ - _common.RspHead(), - ['award', _common.Award(), '奖励信息'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ['mission_chg', _common.Mission(), '任务的最新信息(可能为null客户端需要做容错处理)'], - ] - }, - { - 'name': 'commitAll', - 'desc': '提交所有任务(全部领取)', - 'group': 'Mission', - 'url': 'webapp/index.php?c=Mission&a=commitAll', - 'params': [ - _common.ReqHead(), - ['types', [0], '任务类型数组'], - ], - 'response': [ - _common.RspHead(), - ['award', _common.Award(), '奖励信息'], - ['property_chg', _common.PropertyChg(), '属性变更'], - ] - }, - ] +# -*- coding: utf-8 -*- + +import _common + +class Mission(object): + + def __init__(self): + self.apis = [ + { + 'name': 'missionList', + 'desc': '获取任务列表', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=missionList', + 'params': [ + _common.ReqHead(), + ['type', 0, '任务类型(!!!注意这里的类型和任务表里的任务不是一回事) 1:每日任务 2:赛季周任务 3:悬赏任务'], + ], + 'response': [ + _common.RspHead(), + ['current_day_active_value', 0, '当前日活跃度'], + ['current_week_active_value', 0, '当前周活跃度'], + ['day_active_limit', 0, '每日活跃度上限'], + ['week_active_limit', 0, '每周活跃度上限'], + ['day_time_end', 0, '每日活动结算时间'], + ['week_time_end', 0, '每周活动结算时间'], + ['!mission_list1', [_common.Mission()], '任务列表1'], + ['!mission_list2', [_common.Mission()], '任务列表2'], + ['refreshInfo', RefreshInfo(), '刷新任务信息'], + ] + }, + { + 'name': 'sendOfferRewardMission', + 'desc': '派遣悬赏任务', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=sendOfferRewardMission', + 'params': [ + _common.ReqHead(), + ['mission_id', 0, '任务id'], + ['objects', '', '悬赏任务对象列表type:id|'] + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ['mission_chg', _common.Mission(), '任务的最新信息(可能为null客户端需要做容错处理)'], + ] + }, + { + 'name': 'cancelOfferRewardMission', + 'desc': '撤销派遣悬赏任务', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=cancelOfferRewardMission', + 'params': [ + _common.ReqHead(), + ['mission_id', 0, '任务id'], + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, + { + 'name': 'boostOfferRewardMissionPreview', + 'desc': '加速悬赏任务', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=boostOfferRewardMissionPreview', + 'params': [ + _common.ReqHead(), + ['mission_id', 0, '任务id'], + ], + 'response': [ + _common.RspHead(), + ['boost_chg', 0, '加速所需ceg'], + ] + },{ + 'name': 'boostOfferRewardMission', + 'desc': '加速悬赏任务', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=boostOfferRewardMission', + 'params': [ + _common.ReqHead(), + ['mission_id', 0, '任务id'], + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ['mission_chg', _common.Mission(), '任务的最新信息(可能为null客户端需要做容错处理)'], + ] + }, + { + 'name': 'offerRewardMissionPreview', + 'desc': '悬赏任务奖励预览', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=boostOfferRewardMission', + 'params': [ + _common.ReqHead(), + ['mission_id', 0, '任务id'], + ['objects', '', '悬赏任务对象列表type:id|'] + ], + 'response': [ + _common.RspHead(), + ['!data', _common.AwardItem(), '奖励信息'], + ] + }, + { + 'name': 'commitMission', + 'desc': '提交任务(领取奖励)', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=commitMission', + 'params': [ + _common.ReqHead(), + ['mission_id', 0, '任务id'], + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ['mission_chg', _common.Mission(), '任务的最新信息(可能为null客户端需要做容错处理)'], + ] + }, + { + 'name': 'commitAll', + 'desc': '提交所有任务(全部领取)', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=commitAll', + 'params': [ + _common.ReqHead(), + ['types', [0], '任务类型数组'], + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + },{ + 'name': 'refreshMissionList', + 'desc': '刷新任务', + 'group': 'Mission', + 'url': 'webapp/index.php?c=Mission&a=refreshMissionList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, + ] + + +class RefreshInfo(object): + + def __init__(self): + self.fields = [ + ['refreshTimes', 0, '当前刷新次数'], + ['maxRefreshTimes', 0, '最大刷新次数'], + ['item_id', 0, '消耗道具id'], + ['item_num', 0, '消耗道具数量'], + ] \ No newline at end of file diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 76458d5d..f0423185 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -1,120 +1,121 @@ -_getDailyV(TN_DAILY_REFRESH_MISSION_TIMES, 0); + $maxRefreshTimes = mt\Parameter::getVal('task_refresh_max', 0); + $taskCostParam = explode("|",mt\Parameter::getVal('task_refresh_cost', 10)); + + $key = min($refreshTimes,count($taskCostParam)-1); + + $refreshInfo = array( + "refreshTimes" =>$refreshTimes, + "maxRefreshTimes" =>$maxRefreshTimes, + "item_id" =>V_ITEM_GOLD, + "item_num" =>$taskCostParam[$key], + ); + } $this->_rspData(array( 'current_day_active_value' => min($this->_getDailyV(TN_DAILY_ACTIVE, 0), mt\Parameter::getVal('activeness_limit', 0)), 'current_week_active_value' => min($this->_getWeeklyV(TN_WEEKLY_ACTIVE, 0), mt\Parameter::getVal('max_weekly', 0)), @@ -110,7 +128,8 @@ class MissionController extends BaseAuthedController { 'day_time_end' => $this->_getDaySeconds(time())+3600*24, 'week_time_end' => $this->_getMondaySeconds() + 7*24*3600, 'mission_list1' => $missionDtoList1, - 'mission_list2' => $missionDtoList2 + 'mission_list2' => $missionDtoList2, + 'refreshInfo' => $refreshInfo )); } @@ -325,6 +344,7 @@ class MissionController extends BaseAuthedController { $this->propertyChgService); } + private function procSpecMissionCommit($missionDto, $missionMeta) { switch ($missionMeta['type']) { @@ -363,4 +383,67 @@ class MissionController extends BaseAuthedController { } } + public function refreshMissionList() + { + + $missionMetaList = mt\Task::getCustomTypeMetaList(0, $this->missionService); + $missionHash = Mission::allToHash(); + $missionDtoList = array(); + $refreshList = array(); + $specMissionDto = null; + $num =1; + foreach ($missionMetaList as $missionMeta) { + $num ++; + $missionDb = getXVal($missionHash, $missionMeta['id'], null); + $missionDto = $this->missionService->getMissionDto( + $this->userInfo, $this->seasonDb, $missionDb, $missionMeta); + array_push($missionDtoList, $num); + if ($missionDto['state'] == Mission::NOT_FINISHED_STATE) { + array_push($refreshList, $missionDto['mission_id']); + } + } +// //任务全完成不刷新 + + //刷新次数上限不刷新 + $refreshTimes = $this->_getDailyV(TN_DAILY_REFRESH_MISSION_TIMES, 0); + $maxRefreshTimes = mt\Parameter::getVal('task_refresh_max', 0); + if ($refreshTimes >= $maxRefreshTimes || count($refreshList) < 1){ + $this->_rspErr(1, 'Unable to refresh'); + return; + } + //消耗不足不刷新 + $taskCostParam = explode("|",mt\Parameter::getVal('task_refresh_cost', 10)); + $key = min($refreshTimes,count($taskCostParam)-1); + $costNum = $taskCostParam[$key]; + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => $costNum + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + foreach ($refreshList as $value){ + $this->missionService->updateDailyRewardMission($value); + } + + $this->_incDailyV(TN_DAILY_REFRESH_MISSION_TIMES, 0,1); + $this->_decItems($costItems); + { + //埋点 + $event = [ + 'name' => LogService::REFRESH_MISSION, + 'val' => $costNum + ]; + LogService::consumeGold($event); + } + $this->propertyChgService->addUserChg(); + $this->_rspData(array( + 'property_chg' => $this->propertyChgService->toDto(), + )); + } + } diff --git a/webapp/services/LogService.php b/webapp/services/LogService.php index 867358a0..214d13c9 100644 --- a/webapp/services/LogService.php +++ b/webapp/services/LogService.php @@ -1,235 +1,236 @@ -_getAccountId()); - $data = self::userInfo(); - $data['type'] = self::CONSUME_TYPE; - $data['event_name'] = $event['name']; - $data['event_type'] = self::DIAMOND_TYPE; - $data['event_demand'] = 'diamond'; - $data['event_demand_val'] = $event['val']; - - $logInfo['properties'] = array_merge($data,$param); - - TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); - } - - public static function productGold($event,$param = []) - { - $logInfo = self::goldRecord($param); - $data = self::userInfo(); - $data['type'] = self::PRODUCT_TYPE; - $data['event_name'] = $event['name']; - $data['event_type'] = self::GOLD_TYPE; - $data['event_product'] = 'gold'; - $data['event_product_val'] = $event['val']; - - $logInfo['properties'] = array_merge($data,$param); - TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); - } - public static function productGoldCallback($base, $event,$param = []) - { - $logInfo = self::goldRecord($base); - $data = self::userInfoByAccountId($base['account_id']); - $data['type'] = self::PRODUCT_TYPE; - $data['event_name'] = $event['name']; - $data['event_type'] = self::GOLD_TYPE; - $data['event_product'] = 'gold'; - $data['event_product_val'] = $event['val']; - - $logInfo['properties'] = array_merge($data,$param); - TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); - } - - - public static function productDiamondCallback($base, $event,$param = []) - { - $logInfo = self::diamondRecord($base['account_id']); - $data = self::userInfoByAccountId($base['account_id']); - $data['type'] = self::PRODUCT_TYPE; - $data['event_name'] = $event['name']; - $data['event_type'] = self::DIAMOND_TYPE; - $data['event_product'] = 'diamond'; - $data['event_product_val'] = $event['val']; - - $logInfo['properties'] = array_merge($data,$param); - TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); - } - - public static function consumeItem($event,$param = []) - { - $logInfo = self::ItemRecord(); - $data = self::userInfo(); - $data['type'] = self::CONSUME_TYPE; -// $data['event_name'] = $event['name']; -// $data['event_type'] = self::GOLD_TYPE; - $data['item_id'] = $event['item_id']; - $data['item_num'] = $event['item_num']; - - $logInfo['properties'] = array_merge($data,$param); - - TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); - } - - public static function productItem($event,$param = []) - { - $logInfo = self::ItemRecord(); - $data = self::userInfo(); - $data['type'] = self::PRODUCT_TYPE; -// $data['event_name'] = $event['name']; -// $data['event_type'] = self::GOLD_TYPE; - $data['item_id'] = $event['item_id']; - $data['item_num'] = $event['item_num']; - - $logInfo['properties'] = array_merge($data,$param); - TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); - } - - - private static function userInfo() - { - $user = User::find(myself()->_getAccountId()); - $info = array( - 'account_id' => myself()->_getAccountId(), //账号id - 'channel' => myself()->_getChannel(), //账号channel - 'openid' => myself()->_getOpenId(), //账号openid - 'adress' => myself()->_getAddress(), //账号openid - 'name' => $user['name'], //用户名字 - 'rank' => $user['rank'], //段位 - 'gold' => $user['gold'], //金币 - 'diamond' => $user['diamond'], //钻石 - 'account_register_time' => myself()->_getRegisterTime(), //账号注册时间 - 'ip' => $_SERVER['REMOTE_ADDR'], //用户ip - '_os' => getReqVal('_os', ''), - '_net' => getReqVal('_net', ''), - ); - return $info; - } - - private static function userInfoByAccountId($account_id) { - $user = User::find($account_id); - $info = array( - 'account_id' => $user['account_id'], //账号id - 'channel' => $user['channel'], //账号channel - 'openid' => 'unknown', - 'adress' => $user['address'], //账号openid - 'name' => $user['name'], //用户名字 - 'rank' => $user['rank'], //段位 - 'gold' => $user['gold'], //金币 - 'diamond' => $user['diamond'], //钻石 - 'account_register_time' => $user['createtime'], //账号注册时间 - 'ip' => $_SERVER['REMOTE_ADDR'], //用户ip - '_os' => getReqVal('_os', ''), - '_net' => getReqVal('_net', ''), - ); - return $info; - } - private static function goldRecord($params = []) - { - if (isset($params['account_id']) && !empty($params['account_id'])) { - $account_id = $params['account_id']; - } else { - $account_id = myself()->_getAccountId(); - } - -// $logInfo['log_class'] = $logInfo['log_class']; -// unset($logInfo['log_class']); - $data = array( - "#account_id" => $account_id, - "#event_name"=> "gold_record", - "#ip"=> $_SERVER['REMOTE_ADDR'], - "#time"=> myself()->_getNowTime(), - "#type"=> "track", - "properties"=>'' - ); - return $data; - } - - private static function diamondRecord($account_id) - { - $data = [ - "#account_id" => $account_id, - "#event_name"=> "diamond_record", - "#ip"=> $_SERVER['REMOTE_ADDR'], - "#time"=> myself()->_getNowTime(), - "#type"=> "track", - "properties"=>'' - ]; - return $data; - } - - private static function ItemRecord(){ - $data = [ - "#account_id" => myself()->_getAccountId(), - "#event_name"=> "item_record", - "#ip"=> $_SERVER['REMOTE_ADDR'], - "#controller"=> getReqVal('c', ''), - "#artion"=> getReqVal('a', ''), - "#time"=> myself()->_getNowTime(), - "#type"=> "track", - "properties"=>'' - ]; - return $data; - } -} +_getAccountId()); + $data = self::userInfo(); + $data['type'] = self::CONSUME_TYPE; + $data['event_name'] = $event['name']; + $data['event_type'] = self::DIAMOND_TYPE; + $data['event_demand'] = 'diamond'; + $data['event_demand_val'] = $event['val']; + + $logInfo['properties'] = array_merge($data,$param); + + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + + public static function productGold($event,$param = []) + { + $logInfo = self::goldRecord($param); + $data = self::userInfo(); + $data['type'] = self::PRODUCT_TYPE; + $data['event_name'] = $event['name']; + $data['event_type'] = self::GOLD_TYPE; + $data['event_product'] = 'gold'; + $data['event_product_val'] = $event['val']; + + $logInfo['properties'] = array_merge($data,$param); + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + public static function productGoldCallback($base, $event,$param = []) + { + $logInfo = self::goldRecord($base); + $data = self::userInfoByAccountId($base['account_id']); + $data['type'] = self::PRODUCT_TYPE; + $data['event_name'] = $event['name']; + $data['event_type'] = self::GOLD_TYPE; + $data['event_product'] = 'gold'; + $data['event_product_val'] = $event['val']; + + $logInfo['properties'] = array_merge($data,$param); + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + + + public static function productDiamondCallback($base, $event,$param = []) + { + $logInfo = self::diamondRecord($base['account_id']); + $data = self::userInfoByAccountId($base['account_id']); + $data['type'] = self::PRODUCT_TYPE; + $data['event_name'] = $event['name']; + $data['event_type'] = self::DIAMOND_TYPE; + $data['event_product'] = 'diamond'; + $data['event_product_val'] = $event['val']; + + $logInfo['properties'] = array_merge($data,$param); + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + + public static function consumeItem($event,$param = []) + { + $logInfo = self::ItemRecord(); + $data = self::userInfo(); + $data['type'] = self::CONSUME_TYPE; +// $data['event_name'] = $event['name']; +// $data['event_type'] = self::GOLD_TYPE; + $data['item_id'] = $event['item_id']; + $data['item_num'] = $event['item_num']; + + $logInfo['properties'] = array_merge($data,$param); + + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + + public static function productItem($event,$param = []) + { + $logInfo = self::ItemRecord(); + $data = self::userInfo(); + $data['type'] = self::PRODUCT_TYPE; +// $data['event_name'] = $event['name']; +// $data['event_type'] = self::GOLD_TYPE; + $data['item_id'] = $event['item_id']; + $data['item_num'] = $event['item_num']; + + $logInfo['properties'] = array_merge($data,$param); + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + + + private static function userInfo() + { + $user = User::find(myself()->_getAccountId()); + $info = array( + 'account_id' => myself()->_getAccountId(), //账号id + 'channel' => myself()->_getChannel(), //账号channel + 'openid' => myself()->_getOpenId(), //账号openid + 'adress' => myself()->_getAddress(), //账号openid + 'name' => $user['name'], //用户名字 + 'rank' => $user['rank'], //段位 + 'gold' => $user['gold'], //金币 + 'diamond' => $user['diamond'], //钻石 + 'account_register_time' => myself()->_getRegisterTime(), //账号注册时间 + 'ip' => $_SERVER['REMOTE_ADDR'], //用户ip + '_os' => getReqVal('_os', ''), + '_net' => getReqVal('_net', ''), + ); + return $info; + } + + private static function userInfoByAccountId($account_id) { + $user = User::find($account_id); + $info = array( + 'account_id' => $user['account_id'], //账号id + 'channel' => $user['channel'], //账号channel + 'openid' => 'unknown', + 'adress' => $user['address'], //账号openid + 'name' => $user['name'], //用户名字 + 'rank' => $user['rank'], //段位 + 'gold' => $user['gold'], //金币 + 'diamond' => $user['diamond'], //钻石 + 'account_register_time' => $user['createtime'], //账号注册时间 + 'ip' => $_SERVER['REMOTE_ADDR'], //用户ip + '_os' => getReqVal('_os', ''), + '_net' => getReqVal('_net', ''), + ); + return $info; + } + private static function goldRecord($params = []) + { + if (isset($params['account_id']) && !empty($params['account_id'])) { + $account_id = $params['account_id']; + } else { + $account_id = myself()->_getAccountId(); + } + +// $logInfo['log_class'] = $logInfo['log_class']; +// unset($logInfo['log_class']); + $data = array( + "#account_id" => $account_id, + "#event_name"=> "gold_record", + "#ip"=> $_SERVER['REMOTE_ADDR'], + "#time"=> myself()->_getNowTime(), + "#type"=> "track", + "properties"=>'' + ); + return $data; + } + + private static function diamondRecord($account_id) + { + $data = [ + "#account_id" => $account_id, + "#event_name"=> "diamond_record", + "#ip"=> $_SERVER['REMOTE_ADDR'], + "#time"=> myself()->_getNowTime(), + "#type"=> "track", + "properties"=>'' + ]; + return $data; + } + + private static function ItemRecord(){ + $data = [ + "#account_id" => myself()->_getAccountId(), + "#event_name"=> "item_record", + "#ip"=> $_SERVER['REMOTE_ADDR'], + "#controller"=> getReqVal('c', ''), + "#artion"=> getReqVal('a', ''), + "#time"=> myself()->_getNowTime(), + "#type"=> "track", + "properties"=>'' + ]; + return $data; + } +} diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index 99f74050..182e6a52 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -1447,4 +1447,41 @@ class MissionService extends BaseService { return round($cegNum,2); } + public function updateDailyRewardMission($missionId) + { + + $metas = mt\Task::getDaildyMission(); + $selectMeta = null; + shuffle($metas); + foreach ($metas as $meta) { + if (!$this->inDailyRewardMission($meta['id'])) { + $selectMeta = $meta; + break; + } + } + + if ($selectMeta) { + foreach ($this->dailyMission['missions'] as $k=>&$mission) { + if ($mission['mission_id'] == $missionId) { + $mission['mission_id'] = $selectMeta['id']; + $mission['createtime'] = myself()->_getNowTime(); + $mission['modifytime'] = myself()->_getNowTime(); + $mission['objects'] = array(); + break; + } + } + } + $this->saveDailyMission(); + } + + private function inDailyRewardMission($missionId) + { + foreach ($this->dailyMission['missions'] as $mission) { + if ($mission['mission_id'] == $missionId) { + return true; + } + } + return false; + } + }