<?php
/**
 * aihelp.php
 * Created by: Owen
 * Created on: 2020/12/5 16:16
 */
$lid = 1;
$sid = 2;
define('IN_WEB', true);
include(dirname(__FILE__) . "/../com.php");

$aiHelpData = file_get_contents('php://input');
$aiHelpData = json_decode($aiHelpData, true);
if(!empty($aiHelpData)){
    $uid = $aiHelpData['uid'];
    $giftId = $aiHelpData['giftId'];
    $reward = json_encode(oo::commonOprModel('config')->getAIHelpConf($giftId));
    if(empty($reward)){
        die(json_encode(['flag'=>false,"data"=>""]));
    }
    $created_at = time();
    $expired_at = $created_at + 3*24*60*60;
    $remark = "AI Help 回调奖励";
    $tb  = otable::UserGiftList();
    oo::commonOprDb('userinfo')->query("INSERT INTO {$tb}(uid,`from`,reward,created_at,expired_at,remark) VALUES('{$uid}', '2', '{$reward}', '{$created_at}','{$expired_at}', '{$remark}')");
    oo::commonOprModel('Workerman')->push($uid,ocmd::$send['User_gift'],[]);
    die(json_encode(['flag'=>true,"data"=>""]));
}
die(json_encode(['flag'=>false,"data"=>""]));