public function gamedata($playerID = null, $return = false) { Validate::player($playerID); //we are going to pass all data's $array = array(); //this is what we store the data in. $player = new PlayerModel(); $level = new LevelModel(); $playerLevel = new PlayerLevelModel($playerID); $store = new StoreModel(); $abModel = new ABModel(); $rankModel = new RankModel(); $array['status'] = 'ok'; $array['player'] = $player->getPlayerData(array($playerID, false)); $array['featuretests'] = $abModel->getTests($playerID); $array['scores'] = $playerLevel->load($playerID); $array['stores'] = $store->getStores(); $array['gifts'] = $player->getGifts($playerID); $array['liferequests'] = $player->getRequests($playerID); $array['levels'] = $level->getLevelData(); $array['ranks'] = $rankModel->getRanks(); $levelData = null; $tmpObject = null; if ($return) { return $array; } else { $this->printJson($array); } }
public function getprice() { //we are going to get the item and return the required data to facebook. if (!$_POST['signed_request']) { Log::add('Signed request missing'); } $req = Util::parseSignedRequest($_POST['signed_request']); $payment = $req['payment']; $product = $payment['product']; $quantity = $payment['quantity']; $currency = $payment['user_currency']; $requestID = $payment['request_id']; $method = $_POST['method']; $user = $req['user']; $country = $user['country']; $locale = $user['locale']; $age = $user['age']['min']; $facebookUserID = $req['user_id']; $itemID = substr(strrchr($product, '/'), 1); if (!$itemID) { Log::add('itemID was not found'); } $storeModel = new StoreModel(); $item = $storeModel->getItem($itemID); $return['content'] = array('product' => $product, 'amount' => $item->price / 100 * $quantity, 'currency' => $currency); $return['method'] = $method; $this->printJson($return); }
static function add($data) { if (!$data) { return false; } $model = new StoreModel(); $result = $model->add($data); return $result; }
private function processPayment($objectID) { $playerModel = new PlayerModel(); $storeModel = new StoreModel(); $error = false; $newOrder = false; $graphUrl = sprintf('https://graph.facebook.com/%s?access_token=%s|%s', $objectID, Config::get('facebook.appid'), Config::get('facebook.appsecret')); $curl = new Curl(); $curl->get($graphUrl); if ($curl->error) { Log::add('Error in requesting object ' . $curl->error_code . ' : ' . $curl->error_message); throw new NinjaException("Error Processing Request"); } $res = $curl->response; $facebookID = $res->user->id; $playerArray = $playerModel->getPlayerIDFromUID($facebookID, null, false); $playerID = $playerArray[0]; $orderDetails = $storeModel->addOrder($playerID, $objectID, $res); if ($res->actions[0]->status == 'completed') { $status = 'ok'; Log::add('payment ok charged status is good'); } else { if ($res->actions[0]->status == 'failed') { $error = true; $status = 'error'; $message = 'Payment Declined'; Log::add('Payment failed ' . print_r($res, true)); } else { if ($res->actions[0]->status == 'initiated') { $error = false; Log::add('Payment failed ' . print_r($res, true)); } else { $error = true; $status = 'error'; $message = 'User canceled payment'; } } } //ANALYTICS if (!$error) { $array['status'] = 'ok'; $array['player'] = $playerModel->getPlayerData($playerID); $array['order'] = $orderDetails; $this->printJson($array); } else { $array['status'] = 'error'; $array['message'] = $message; $this->printJson($array); } }
/** * 获取可以生产多少个产物products * * @param $raw_materials Map数据库里存的已添加的原料信息 * @param $id 当前的物品 */ private function num_complete_raw_materials($raw_materials, $itemId) { if (!$raw_materials || !isset($itemId)) { return 0; } $length = 100; // 这个值是定值,如果没有变化的话,说明没有产物的 $storeModel = new StoreModel($this->lang); $storeItem = $storeModel->getStoreById($itemId); $raw_material = $storeItem->raw_material; // store 里的信息// 先取出来 $raw_materials = $raw_materials ? $raw_materials : array(); // 数据库里存的信息 for ($i = 0; $i < count($raw_material); $i++) { if (!isset($raw_materials[$i]) || !is_array($raw_materials[$i])) { return 0; } if ($length > count($raw_materials[$i])) { $length = count($raw_materials[$i]); } } if ($length == 100) { return 0; } return $length; }
function paymentcallback($data = null) { $store = new StoreModel(); $data['transactionid'] = filter_input(INPUT_POST, 'transactionid'); $data['gameruserid'] = filter_input(INPUT_POST, 'gameuserid'); $data['currency'] = filter_input(INPUT_POST, 'currency'); $data['amount'] = filter_input(INPUT_POST, 'amount'); $data['paymentResult'] = filter_input(INPUT_POST, 'paymentresult'); $data['paymenttransactionid'] = filter_input(INPUT_POST, 'paymenttransactionid'); $data['paymenterrormessage'] = filter_input(INPUT_POST, 'paymenterrormessage'); $data['session'] = filter_input(INPUT_POST, 'session'); $data['version'] = filter_input(INPUT_POST, 'version'); $data['auth'] = filter_input(INPUT_POST, 'auth'); //check to see if transaction id exitsts list($hasOrder, $response) = $store->getYahooPendingOrder($data); Log::add('Has Order: ' . $hasOrder . ' and response: ' . print_r($response, true)); if ($hasOrder) { //lets do some comparing amount/name $message = "success"; } else { $message = "error"; } //check to see if A) we have a trans action ID //if so! then we match the amount //and then we f**k just kill shit. echo "success"; Log::add('Yahoo Payment Callback Called?!'); }
public function dodo() { $file = 'data/retrieve_data.retrieve.1279381815334.response'; $content = file_get_contents($file); $data = unserialize($content); unset($content); echo '<pre>'; $store = new StoreModel(); $tmp = $store->getData(); foreach ($tmp as &$row) { // 单个产品为 数字,多个产品为 数组 $row->raw_material = trim($row->raw_material) && !is_numeric($row->raw_material) ? unserialize($row->raw_material) : ''; $row->product = trim($row->product) && !is_numeric($row->product) ? unserialize($row->product) : ''; $row->materials = trim($row->materials) && !is_numeric($row->materials) ? unserialize($row->materials) : ''; $row->upgrade_levels = trim($row->upgrade_levels) && !is_numeric($row->upgrade_levels) ? unserialize($row->upgrade_levels) : ''; foreach ($row as $key => $val) { if (is_string($val) && trim($val) == '' || is_null($val)) { unset($row->{$key}); } unset($row->status, $row->addtime); } } foreach ($data->config->store as $row) { //echo $row->id . "\t" . count((array)$row) . "\t" . count((array)$tmp[($row->id - 1)]) . "\n"; echo $row->id; print_r(array_diff((array) $row, (array) $tmp[$row->id - 1])); } unset($data->config); //echo var_export($data, true); echo '</pre>'; }
public function cuidan() { $order_id = $this->gp['order_id']; import('ORG.Util.Cookie'); if (Cookie::get("cd_{$order_id}")) { $this->myError('催单频繁,请稍后再试'); } $order = OrderModel::I()->getOrderById($order_id); $store = StoreModel::I()->getStoreBySid($order['store_id']); if (mobile_sms($store['mobile'], "订单号为{$order['order_sn']}的订单请尽快配送,买家催单", $this->setting)) { /* if($store['sms_num']>0){ M('setting')->where("setting_key='site_sms_num'")->setDec('setting_key'); } */ } else { $this->myError('催单失败'); } $this->setting['cuidan'] = $this->setting['cuidan'] ? intval($this->setting['cuidan']) : 5; Cookie::set("cd_{$order_id}", 1, 60 * $this->setting['cuidan']); $this->mySuccess('催单成功'); }