public function testExchange() { $ExchangeInfo['Comment'] = json_encode(array('ProductPackCode' => 'jChrsrjMs')); $ExchangeInfo['AppId'] = 101; $ExchangeInfo['ExchangeId'] = '1234567896134567489'; $oProduct = new Config_Product_Product(); $oProductPack = new Config_Product_Pack(); $Comment = json_decode($ExchangeInfo['Comment'], true); //移除道具发送队列 $remove = $oProduct->removeSentLog($Comment['ProductPackCode'], $ExchangeInfo['AppId'], 0); //获取礼包信息 $PackCode = $oProductPack->getProductPackCode($Comment['ProductPackCode']); //解开备注字段 $C = json_decode($PackCode['Comment']); //添加兑换ID $C['ExchangeId'] = $ExchangeInfo['ExchangeId']; //更新兑换ID $oProductPack->updatePackCode($Comment['ProductPackCode'], array('Comment' => json_encode($C))); }
/** *礼包码详情 */ public function getProductPackCodeDetailAction() { //基础元素,必须参与验证 $User['UserId'] = abs(intval($this->request->UserId)); $User['ProductPackCode'] = $this->request->ProductPackCode; $User['Time'] = abs(intval($this->request->Time)); $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2; //URL验证码 $sign = $this->request->sign; //私钥,以后要移开到数据库存储 $p_sign = 'lm'; $sign_to_check = base_common::check_sign($User, $p_sign); //不参与验证的元素 //验证URL是否来自可信的发信方 if ($sign_to_check == $sign) { if ($User['UserId']) { //验证时间戳,时差超过600秒即认为非法 if (abs($User['Time'] - time()) <= 600) { //查询用户 $UserInfo = $this->oUser->GetUserById($User['UserId']); if ($UserInfo['UserId']) { unset($User['ReturnType']); $oProductPack = new Config_Product_Pack(); $ProductPackCode = $this->oProductPack->getUserProductPackCode($User['ProductPackCode'], $User['UserId']); if (!$ProductPackCode['ProductPackCode']) { $ProductPackCode = $oProductPack->getProductPackCode($User['ProductPackCode']); } if ($ProductPackCode['ProductPackCode']) { if ($ProductPackCode['AsignUser'] != $User['UserId'] && $ProductPackCode['AsignUser'] > 0) { $result = array('return' => 2, 'comment' => "您不是此礼包的指定使用人"); } else { if ($ProductPackCode['UsedUser'] != $User['UserId'] && $ProductPackCode['UsedUser'] > 0) { $result = array('return' => 2, 'comment' => "您不是此礼包的使用人"); } else { $oSkin = new Config_Skin(); $oHero = new Config_Hero(); $oMoney = new Config_Money(); $oApp = new Config_App(); $ProductPack = $oProductPack->getRow($ProductPackCode['ProductPackId']); $Comment = json_decode($ProductPack['Comment'], true); if (is_array($Comment)) { unset($ProductList); foreach ($Comment as $Type => $TypeInfo) { foreach ($TypeInfo as $ProductId => $Count) { if (!isset($ProductInfo[$Type][$ProductPack['AppId']][$ProductId])) { if ($Type == "hero") { $ProductInfo[$Type][$ProductPack['AppId']][$ProductId] = $oHero->getRow($ProductId, $ProductPack['AppId'], '*'); } elseif ($Type == "skin") { $ProductInfo[$Type][$ProductPack['AppId']][$ProductId] = $oSkin->getRow($ProductId, $ProductPack['AppId'], '*'); } elseif ($Type == "product") { $ProductInfo[$Type][$ProductPack['AppId']][$ProductId] = $oProduct->getRow($ProductId, $ProductPack['AppId'], '*'); } elseif ($Type == "money") { $ProductInfo[$Type][$ProductPack['AppId']][$ProductId] = $oMoney->getRow($ProductId, $ProductPack['AppId'], '*'); } elseif ($Type == "appcoin") { $AppInfo = $oApp->getRow($ProductPack['AppId']); $comment = json_decode($AppInfo['comment'], true); $ProductInfo[$Type][$ProductPack['AppId']][$ProductId]['name'] = $comment['coin_name']; } } $ProductList[$Type]['detail'][$ProductId] = $ProductInfo[$Type][$ProductPack['AppId']][$ProductId]['name'] . "*" . $Count . "个"; } $TypeList[$Type] = implode(",", $ProductList[$Type]['detail']); } $ProductPack['ProductListText'] = implode(",", $TypeList); } else { $ProductPack['ProductListText'] = "无道具"; } $result = array('return' => 1, 'ProductPack' => $ProductPack, 'ProductPackCode' => $ProductPackCode); } } } else { $result = array('return' => 0, 'comment' => "无此礼包码"); } } else { $result = array('return' => 2, 'comment' => "无此用户"); } } else { $result = array('return' => 2, 'comment' => "时间有误"); } } else { $result = array('return' => 0, 'comment' => "请选择用户"); } } else { $result = array('return' => 2, 'comment' => "验证失败,请检查URL"); } $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2; if ($User['ReturnType'] == 1) { echo json_encode($result); } }