$giftAmount = 1; } for ($i = 0; $i < $giftAmount; $i++) { if ($giftAmount > 1) { $targetGiftType = $giftContent[0][$i]; $targetGiftIndex = $giftContent[1][$i]; $targetGiftAmount = $giftContent[2][$i]; } else { $targetGiftType = $giftContent[0]; $targetGiftIndex = $giftContent[1]; $targetGiftAmount = $giftContent[2]; } switch ($targetGiftType) { case 0: //cashcard $CashCardSet = NiuGameSetting::findFirst("gskey = 'Niu_CashCardSet'")->value; //$DiamondCost = $CashCardSet[$targetGiftIndex][0]; $DepositMax = $CashCardSet[$targetGiftIndex][1]; //giving a CashCard $NTItem = new NiuTransferableItem(); $NTItem->buyerUUID = (int) $uuid; $NTItem->ownerUUID = (int) $uuid; $NTItem->itemType = "cashcard"; $NTItem->maxDeposit = $DepositMax; $NTItem->created_at = $app->sfunc->getGMT(); $NTItem->save(); $bankRec = new NiuBankRecord(); $bankRec->uuid = (int) $uuid; $bankRec->value = 0; $bankRec->usingDiamond = 0; $bankRec->gcardid = $NTItem->id;
break; case "Diamond": // diamond purchase if (!isset($inputs["ProductIdentifier"])) { $app->sfunc->badRequest400($app, "ProductIDMissing"); } if (!isset($inputs["TransactionReceipt"])) { $app->sfunc->badRequest400($app, "TransReceiptMissing"); } if (!isset($inputs["PurchaseAgency"])) { $app->sfunc->badRequest400($app, "AgentMissing"); } if ($inputs["PurchaseAgency"] == "google" && !isset($inputs["RawPurchaseData"])) { $app->sfunc->badRequest400($app, "RawDataMissing"); } $DiamondSet = NiuGameSetting::findFirst("gskey = 'Niu_DiamondSet'")->value; // int[]{123,340,464,1022,3100,5280} //$RealCashCost = $DiamondSet[$targetIndex][0];// not using/no value at this moment $DiamondCost = 0; $DiamondDeposit = $DiamondSet[$targetIndex]; $numberFromProductID = preg_replace('/\\D/', '', $inputs["ProductIdentifier"]); // "currency_sycee3100" -> 3100 //make sure DiamondDeposit and the number client claimed are matched if ($numberFromProductID != $DiamondDeposit) { $app->sfunc->badRequest400($app, "ProductIDMisMatching"); } break; default: $targetType = "unknown"; $targetItemType = $inputs["objType"]; $app->sfunc->badRequest400($app, "UnknownTarget");