when writing a lottery, when opening a lottery, the winning information is stored in redis, and then the following code is written to call it. Please check whether it is used correctly
. public function giveOutGoldFoins()
{
$object = new cache();
$userObj = new user();
$UserFundsLog = new UserFundsLog();
$cathectic = new cathectic();
while (true) {
try{
$data = $object->lpop("win_the_lottery");
if(false == $data){
break;
}
$logData = json_decode($data,true);
//
$sql = "UPDATE `ct_user` SET `gold` = gold+".$logData["money"]." WHERE `id` = ".$logData["user_id"];
$result = $userObj->updateData($sql,[]);
//
$sql = "UPDATE `ct_cathectic` SET `state`=1 WHERE id=".$logData["id"];
$res = $cathectic->updateData($sql,[]);
//
$log = [
":user_id" => $logData["user_id"],
":classify"=> MONEY_FLOW_LOTTERY,
":number" => $logData["money"],
":before_num" => $logData["gold"],
":after_num" => $logData["gold"]+$logData["money"],
":explain" => ":".$logData["issue"].",".$logData["money"]."",
":data" => $logData["data"],
":create_time"=> time(),
];
$sql = "INSERT INTO `lottery`.`ct_user_funds_log` (`user_id`, `classify`, `number`, `before_num`, `after_num`, `explain`, `data`, `create_time`) VALUES (:user_id, :classify, :number, :before_num, :after_num, :explain, :data, :create_time)";
$UserFundsLog->addData($sql,$log);
}catch(Exception $e){
file_put_contents(".log",$e->getMessage().PHP_EOL, FILE_APPEND);
}
}
}