| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace App\Http\Controllers\Cash;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request;
- use App\Models\Login\AccountInfo;
- use App\Models\User\CashShopAll;
- use App\Models\Web\HistoryShopBuyedItem;
- class CashShopController extends Controller
- {
- public function inquiryBalance(Request $request)
- {
- if(isset($request['userId'])){
- $userID = $request['userId'];
- $realBalance = 0;
- $bonusBalance = 0;
- $cashAccount = AccountInfo::where('Username', $userID)->first();
- if($cashAccount){
- $realBalance = $cashAccount->Real_Balance != null ? $cashAccount->Real_Balance : 0;
- $bonusBalance = $cashAccount->Bonus_Balance != null ? $cashAccount->Bonus_Balance : 0;
- return response()->json([
- 'result' => 'success',
- 'realCash' => intval($realBalance),
- 'bonusCash' => intval($bonusBalance)
- ],400);
- }
- }
- return response()->json([
- 'service_code' => '',
- 'Result' => -97
- ],400);
- }
- public function nexonCash(Request $request)
- {
- if(isset($request['userId'])){
- $userID = $request['userId'];
- $realBalance = 0;
- $bonusBalance = 0;
- $cashAccount = AccountInfo::where('Username', $userID)->first();
- if($cashAccount){
- $realBalance = $cashAccount->Real_Balance != null ? $cashAccount->Real_Balance : 0;
- $bonusBalance = $cashAccount->Bonus_Balance != null ? $cashAccount->Bonus_Balance : 0;
- return response()->json([
- 'result' => 'success',
- 'realCash' => intval($realBalance),
- 'bonusCash' => intval($bonusBalance)
- ],400);
- }
- }
- return response()->json([
- 'service_code' => '',
- 'Result' => -97
- ],400);
- }
- public function purchaseItem(Request $request)
- {
- $makeCodeNo = 0;
- $userNo = 0;
- $userId = '';
- $itemId = '';
- $itemCnt = 0;
- $itemUnitPrice = 0;
- $gameServerNo = 0;
- $statProperty1 = '';
- $statProperty2 = '';
- $statProperty3 = '';
- $location = '';
- $clientIp = '';
- $channelingUserId = '';
- $charId = 0;
- $data = explode('&', $_SERVER['QUERY_STRING']);
- foreach ($data as $param) {
- list($name, $value) = explode('=', $param, 2);
- if ($name == 'makeCodeNo') {
- $makeCodeNo = $value;
- }
- if ($name == 'userNo') {
- $userNo = $value;
- }
- if ($name == 'userId') {
- $userId = $value;
- }
- if ($name == 'itemInfos[0].itemId') {
- $itemId = $value;
- }
- if ($name == 'itemInfos[0].itemCnt') {
- $itemCnt = $value;
- }
- if ($name == 'itemInfos[0].itemUnitPrice') {
- $itemUnitPrice = $value;
- }
- if ($name == 'gameServerNo') {
- $gameServerNo = $value;
- }
- if ($name == 'statProperty1') {
- $statProperty1 = $value;
- }
- if ($name == 'statProperty2') {
- $statProperty2 = $value;
- }
- if ($name == 'statProperty3') {
- $statProperty3 = $value;
- }
- if ($name == 'location') {
- $location = $value;
- }
- if ($name == 'ClientIp') {
- $clientIp = $value;
- }
- if ($name == 'ChannelingUserId') {
- $channelingUserId = $value;
- }
- if ($name == 'charId') {
- $charId = $value;
- }
- }
- $datajson = null;
- $userId = str_replace('@KLONER', '', $userId);
- $Account = AccountInfo::where('Username', $userId)->first();
- $chekProdInfo = CashShopAll::GetProduct($itemId);
- if ($chekProdInfo != null) {
- $linkItemID = $chekProdInfo[0]->LinkItemID;
- $itemPrase = $chekProdInfo[0]->Price;
- $itemCount = $chekProdInfo[0]->Count;
- if ($itemCnt == $itemCount) {
- $realBalance = $Account->Real_Balance != null ? $Account->Real_Balance : 0;
- $bonusBalance = $Account->Bonus_Balance != null ? $Account->Bonus_Balance : 0;
- $totalBalance = $realBalance + $bonusBalance;
- if ($totalBalance >= $itemPrase) {
- $totalBalance = $totalBalance - $itemPrase;
- AccountInfo::UpdateBalance($Account->Username, $totalBalance);
- HistoryShopBuyedItem::SaveHistory($Account->AccountDBID, $linkItemID, $itemCount, $itemPrase);
-
- $datajson = '{
- "statProperty2": null,
- "statProperty1": "' . $statProperty1 . '",
- "statProperty3": "success",
- "realCash": ' . $realBalance . ',
- "bonusCash": 0,
- "chargedCashAmt": ' . $itemPrase . ',
- "itemInfos": [
- {
- "itemCnt": ' . $itemCount . ',
- "itemId": "' . $linkItemID . '",
- "itemUnitPrice": ' . $itemPrase . '
- }
- ]
- }';
- die($datajson);
- }else{
- $datajson = [
- 'statProperty2' => '1009996'
- ];
- }
- }else{
- $datajson = [
- 'statProperty2' => '1001002'
- ];
- }
- }else{
- $datajson = [
- 'statProperty2' => '1001002'
- ];
- }
- return response()->json($datajson, 200);
- }
- // Получение RecId и LinkItemID предметов из таблицы CashShopAll
- public function getItemsDetails(Request $request)
- {
- // возвращает RecId и LinkItemID предметов из таблицы CashShopAll
- $itemDetails = CashShopAll::all(['RecId', 'LinkItemID']);
- return response()->json($itemDetails, 200);
- }
- }
|