Beispiel #1
0
 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));
     }
 }
Beispiel #2
0
 function action_gen_leaguewar()
 {
     $section_list = array_keys(getApp()->getSectionConfig());
     $lw = new LeagueWar();
     try {
         foreach ($section_list as $sec) {
             $lw->genBattleConf($sec);
         }
     } catch (Exception $e) {
         $ex_msg = $e->getMessage();
         $ex_trace_msg = $e->getTraceAsString();
         $excep_content = "{$ex_msg}\n{$ex_trace_msg}";
         $subject = "leaguewar_init_bug_" . P_PLATFORM . "_" . date('Y-m-d H:i:s', time());
         $email_content = "盟战初始化错误. {$excep_content}";
         model_Util::sendemail('*****@*****.**', $subject, $email_content);
     }
 }