public function actionBuchangGem() { glog::info(json_encode($_REQUEST), 'addgem'); glog::info(json_encode($_SERVER), 'addgem'); $hour = date("H"); if ($hour < 10 || $hour > 21) { // 10:00 ~ 21:59 才能使用这个接口,防止阿里云的云盾自动发起回调... // 有没有更好的处理方法... return $this->response(array('s' => 'ERROR', 'msg' => '操作时间不合法')); } $keys = array('section_id', 'product_id', 'platform', 'operator', 'optime'); $params = array(); foreach ($keys as $key) { ${$key} = trim(self::getParam($key)); if (empty(${$key})) { $msg = "need param [{$key}]"; glog::info($msg, 'addgem'); return $this->response(array('s' => 'ERROR', 'msg' => $msg)); } $params[$key] = ${$key}; } $now = time(); if ($now - $params['optime'] > 60 || $params['optime'] - $now > 60) { return $this->response(array('s' => 'ERROR', 'msg' => '操作已过期')); } $pid = self::getParam('pid'); if ($pid) { $um = model_LoginUser::searchUniq('pid', $pid); if (!$um) { return $this->response(array('ErrorCode' => 0, 'ErrorDesc' => "用户[{$pid}]不存在")); } $uid = $um->id(); } else { $uid = self::getParam('uid'); } if (empty($uid)) { return $this->response(array('s' => 'ERROR', 'msg' => "需要UID参数")); } if ($params['platform'] != P_PLATFORM) { return $this->response(array('s' => StatusCode::error, 'msg' => "平台信息不匹配")); } if ($product_id == 'custom') { if (!in_array(P_PLATFORM, array('qqandroid', 'kunlun'))) { return $this->response(array('s' => StatusCode::error, 'msg' => P_PLATFORM . "平台不支持自定义额度支付")); } $params['cash'] = trim(self::getParam('cash')); if (!is_numeric($params['cash']) || $params['cash'] <= 0) { return $this->response(array('s' => StatusCode::error, 'msg' => "自定义额度{$params['cash']}不合法")); } } else { $payment_config = getApp()->getPaymentConifg(); if (!isset($payment_config[$product_id])) { $msg = "product_id[{$product_id}] not exists"; glog::info($msg, 'addgem'); return $this->response(array('s' => 'ERROR', 'msg' => $msg)); } } // 验证参数 if (0 && !isset($_REQUEST['__no_sig__']) && !$this->verify_signature($params, 'qxs%Mt6v@nVdUb9d')) { return $this->response(array('s' => 'ERROR', 'msg' => "signature verification failed")); } PL_Session::$usecookie = false; $_REQUEST['cid'] = PL_Session::gencid($uid, $section_id); $player = getApp()->getPlayer(); $mon = getApp()->getPaymentMongoConnection(); $mongoid = new MongoID(); $transaction_id = $mongoid->{'$id'}; // 生成新的订单信息 $payment_info = $player->createPaymentInfo($product_id); if ($product_id == 'custom') { $payment_info['cash'] = $params['cash']; if (P_PLATFORM == 'kunlun') { $payment_info['sumGem'] = $payment_info['cash'] * 15; } } $payment_info['transaction_id'] = $transaction_id; $payment_info['create_t'] = getApp()->now; $payment_info['source'] = 'buchang'; $payment_info['msg'] = $params['operator'] . "给玩家补偿未到账的支付,"; $old_vip = $payment_info['_vip']; $old_gem = $payment_info['ogem']; // 订单上次处理异常 或者 新的订单 $ret = $player->process_payment($payment_info); if ($ret['s'] == StatusCode::ok) { $msg = "transaction [{$transaction_id}] processed"; glog::info($msg, 'addgem'); if (1) { $gem_add_and_reward = $ret['info']['gem_add_and_reward']; // 补发传书 $msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "您未到账的{$gem_add_and_reward}元宝已经补发到账,祝您游戏愉快~"); model_Chat::sendMsg($msg, $uid, 'origin', $section_id); } else { $gem_add_and_reward = $ret['info']['gem_add_and_reward']; $reward_gem = ceil($gem_add_and_reward * 0.1); // 补发传书 $msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "您未到账的{$gem_add_and_reward}元宝已经补发到账,现在额外补偿您{$reward_gem}元宝,祝您游戏愉快~"); $awards = array(array('tag' => 'gem', 'num' => $reward_gem)); $msg['status'] = 'award'; $cdkey = model_Cdkey::gen($awards, "{$reward_gem}元宝"); $msg['cdkey'] = $cdkey; model_Chat::sendMsg($msg, $uid, 'origin', $section_id); } // 发邮件 $login_model = new model_LoginUser($uid); $login_model->get(array('pid' => 1, 'email' => 1)); $pid = $login_model['pid']; $email = $login_model['email']; $login_model->opOne('buchange_gem_t', getApp()->now); $login_model->save(); $new_gem = $player->numberGet('base', 'gem'); $new_vip = $player->numberGet('vip', 'lvl'); $platform = P_PLATFORM; $name = $player->stringGet('base', 'name'); $cash = $payment_config[$product_id]['cash']; $operator = $params['operator']; $subject = "[{$operator}]BuChangChongZhi[{$platform}][{$section_id}][{$uid}][{$cash} yuan]"; $time = date("Y-m-d H:i:s"); $content = "操作时间: {$time} \n"; $content .= "操作人:{$operator}\n平台: {$platform}\nPID:{$pid}\nemail:{$email}\nUID:{$uid}\n分区:{$section_id}\n门派名:{$name}\n"; $content .= "充值前:\nvip:{$old_vip}\ngem:{$old_gem}\n"; $content .= "充值后:\nvip:{$new_vip}\ngem:{$new_gem}\n"; model_Util::sendemail('*****@*****.**', $subject, $content); return $this->response(array('s' => 'OK', 'msg' => $msg, 'ret' => $ret)); } else { $msg = "transaction[{$transaction_id}] failed," . $ret['msg']; glog::info($msg, 'addgem'); return $this->response(array('s' => 'ERROR', 'msg' => $msg, 'ret' => $ret)); } }
public function action_import_realtime() { /* $section = $this->get_param('sec'); $source = $this->get_param('src');*/ $period = $this->get_param('period'); $bDate = $this->get_param('begin'); $eDate = $this->get_param('end'); $secList = array_keys(getApp()->getSectionConfig()); $srcList = array_keys(getApp()->getSourceConfig()); $allList = array($secList, $srcList, array("all")); $login_model = new model_LoginUser(1); // 1? for ($i = 0, $len1 = count($allList); $i < $len1; $i++) { $tmpList = $allList[$i]; for ($j = 0, $len2 = count($tmpList); $j < $len2; $j++) { $elem = $tmpList[$j]; echo $elem . "\n"; if ($i == 0) { //分区 $ret = model_Util::get_realtime_login_stat_new($period, $elem, $bDate, $eDate); $tmp = array('Section' => array($elem => $data)); $data =& $tmp['Section'][$elem]; } else { if ($i == 1) { //渠道 $ret = model_Util::get_realtime_login_stat_new($period, $elem, $bDate, $eDate); $tmp = array('Source' => array($elem => $data)); $data =& $tmp['Source'][$elem]; } else { if ($i == 2) { //总表 $ret = model_Util::get_realtime_login_stat_new($period, $elem, $bDate, $eDate); $tmp = array('All' => $data); $data =& $tmp['All']; } } } $datas = $ret["data"]; foreach ($datas as $day => $vals) { $login_model->id($day, 'realtime_stat'); $data = array('date' => $vals['date'], 'active_today_pid' => $vals['active_today_pid'], 'auth_today_pid' => $vals['auth_today_pid'], 'auth_yesterday_pid' => $vals['auth_yesterday_pid'], 'auth_reserve_pid' => $vals['auth_reserve_pid'], 'active_today_device' => $vals['active_today_device'], 'auth_today_device' => $vals['auth_today_device'], 'auth_yesterday_device' => $vals['auth_yesterday_device'], 'auth_reserve_device' => $vals['auth_reserve_device']); echo $vals["date"] . "\n"; var_dump($tmp); $login_model->opMulti($tmp); $login_model->save(); } } } /* if($section && !$source){//分区 $ret = model_Util::get_realtime_login_stat_new($period, $section); $tmp = array('Section'=>array($section=>$data)); $data = &$tmp['Section'][$section]; }else if($source && !$section){//渠道 $ret = model_Util::get_realtime_login_stat_new($period, $source); $tmp = array('Source'=>array($source=>$data)); $data = &$tmp['Source'][$source]; }else if(!$section && !$source){//总表 $ret = model_Util::get_realtime_login_stat_new($period, 'all'); $tmp = array('All'=>$data); $data = &$tmp['All']; } $datas = $ret["data"]; var_dump($ret); foreach($datas as $day=>$vals){ $login_model->id($day,'realtime_stat'); $data = array( 'date'=>$vals['date'] ,'active_today_pid'=>$vals['active_today_pid'] ,'auth_today_pid'=>$vals['auth_today_pid'] ,'auth_yesterday_pid'=>$vals['auth_yesterday_pid'] ,'auth_reserve_pid'=>$vals['auth_reserve_pid'] ,'active_today_device'=>$vals['active_today_device'] ,'auth_today_device'=>$vals['auth_today_device'] ,'auth_yesterday_device'=>$vals['auth_yesterday_device'] ,'auth_reserve_device'=>$vals['auth_reserve_device'] ); $login_model->opMulti($tmp); $login_model->save(); } echo "finished..."; */ // var_dump($datas); /* $login_model->switchColl('realtime_stat'); $ret = $login_model->getByIds(array('2013-01-08')); var_dump($ret);*/ // $ret = model_Util::realtime_stat_by_sec($period, $sec); // echo $ret; //$ret = $ret["data"];//["2013-01-07"]; // $cnt = 0; /* foreach ($ret as $k=>$v){ echo $k." === ".$v; echo "\n"; $cnt ++; }*/ // echo $cnt; // var_dump($total_user_count_pid); /* $login_model = new model_LoginUser(1); $login_model->id('2013-01-08','realtime_stat'); $login_model->opOne('name','owen'); $login_model->opMulti(array('age'=>100,'xxx'=>'yyy')); $login_model->save(); $login_model = new model_LoginUser(1); $login_model->switchColl('realtime_stat'); $ret = $login_model->getByIds(array('2013-01-08')); var_dump($ret);*/ }