//bank Record $bankRec = new NiuBankRecord(); $bankRec->uuid = (int) $uuid; $bankRec->usingCash = 0; $bankRec->usingDiamond = 0; $bankRec->value = $targetGiftAmount; $bankRec->giftid = $val; $bankRec->type = "Gift"; //gift $bankRec->save(); break; case 2: //cash $thsUser->cash += $targetGiftAmount; //bank Record $bankRec = new NiuBankRecord(); $bankRec->uuid = (int) $uuid; $bankRec->usingCash = 0; $bankRec->usingDiamond = 0; $bankRec->value = $targetGiftAmount; $bankRec->giftid = $val; $bankRec->type = "Gift"; //gift $bankRec->save(); break; case 3: //eq //eq case 4: // TableBG // TableBG
break; } if (!$targetItem) { $app->sfunc->badRequest400($app, "ItemNotFound"); } $app->sfunc->isValidPurchase($targetItem, $user, $app); try { // Check that an access token is present and is valid $app->oauth->resource->isValidRequest(); //now pruchase the specific item $user->NiuUsrOwnItem->PurchaseByID($idToPurchase); $user->cash -= $targetItem->cashCost; $user->diamond -= $targetItem->diamondCost; $user->save(); //insert record to NiuBankRecord $record = new NiuBankRecord(); $record->value = $targetItem->cashCost > 0 ? -$targetItem->cashCost : -$targetItem->diamondCost; //int $record->type = "NiuNiu"; $record->uuid = $uuid; $record->usingDiamond = $targetItem->diamondCost; //int $record->usingCash = $targetItem->cashCost; //int //$record->ugid = -1;//long? //$record->gcardid = -1;//long? //$record->created_at = $app->sfunc->getGMT();// server default GMT $record->save(); $app->sfunc->jsonOutput($app, array('status' => 200)); } catch (\Exception $e) { //var_dump($e);