}
});
$app->post('/resource/niugift/sendgift/{uuid:[0-9]+}', function ($uuid) use($app) {
    $inputs = $app->sfunc->getContentTypeFromPost();
    if (!isset($inputs["targets"])) {
        $app->sfunc->badRequest400($app, "targetMissing");
    }
    $targets = $app->sfunc->convertStringToIntArray($inputs["targets"]);
    try {
        // Check that an access token is present and is valid
        $app->oauth->resource->isValidRequest();
        //get and check the user id by AccessToken
        $app->sfunc->isValidUUID($app, $uuid);
        $outputString = "";
        foreach ($targets as $val) {
            $gBoxEntry = new GiftBox();
            $gBoxEntry->originid = $uuid;
            $gBoxEntry->origintype = isset($inputs['ot']) ? $inputs['ot'] : "0";
            $gBoxEntry->targettype = isset($inputs['tt']) ? $inputs['tt'] : "0";
            if (isset($inputs['co'])) {
                $gBoxEntry->content = $inputs['co'];
            }
            if (isset($inputs['json'])) {
                $gBoxEntry->json = $inputs['json'];
            }
            // example: 2_0_1000
            $gBoxEntry->created_at = $app->sfunc->getGMT();
            $gBoxEntry->expired_at = isset($inputs['expired']) ? $app->sfunc->getGMT($inputs['expired']) : $app->sfunc->getGMT(259200);
            //3 day by default
            $gBoxEntry->targetid = $val;
            $gBoxEntry->save();
 if (!$card) {
     $app->sfunc->notFunction404($app, "CardNotFound");
 }
 //now create a CASH giftcontent in Text
 $giftContent = "2_0_" . $card->nowDeposit;
 $targetPlayer = NiuUsrInfo::findFirst("id = " . (int) $inputs["targetplayer"]);
 if (!$targetPlayer) {
     $app->sfunc->notFunction404($app, "TargetUserNotFound");
 }
 try {
     // Check that an access token is present and is valid
     $app->oauth->resource->isValidRequest();
     //get and check the user id by AccessToken
     $app->sfunc->isValidUUID($app, $uuid);
     //send a gift to targetgift
     $AGift = new GiftBox();
     $AGift->originid = $uuid;
     $AGift->origintype = 2;
     //niuniu
     $AGift->targetid = $targetPlayer->id;
     $AGift->targettype = 2;
     //niuniu
     $AGift->content = isset($inputs['content']) ? $inputs['content'] : "";
     $AGift->json = $giftContent;
     $AGift->created_at = $app->sfunc->getGMT();
     $AGift->expired_at = isset($inputs['expired']) ? $app->sfunc->getGMT($inputs['expired']) : $app->sfunc->getGMT(259200);
     //3 day by default
     $AGift->save();
     //disable the cashcard
     $card->ownerUUID = -$card->ownerUUID;
     $card->save();