我正在建立一个新的网站,我有这个cron作业脚本自动更新所有投资
错误似乎来自http控制器(行:$rLog['amount'] = round(($rep->invest->amount * $rep->invest->plan->percent) / 100,$basic->deci);)。
但我不知道如何修复它,因为我对laravel完全陌生
if ($basic->repeat_status == 1){
$repeats = Repeat::whereStatus(0)->get();
foreach ($repeats as $rep){
if ($rep->repeat_time < Carbon::now()){
$rLog['user_id'] = $rep->user_id;
$rLog['trx_id'] = strtoupper(Str::random(20));
$rLog['investment_id'] = $rep->investment_id;
$rLog['made_time'] = Carbon::now();
$rLog['amount'] = round(($rep->invest->amount * $rep->invest->plan->percent) / 100,$basic->deci);
RepeatLog::create($rLog);
$rep->total_repeat = $rep->total_repeat + 1;
$rep->made_time = Carbon::now();
$rep->repeat_time = Carbon::parse()->addHours($rep->invest->plan->compound->compound);
if ($rep->total_repeat == $rep->invest->plan->time){
$rep->status = 1;
$inv = Investment::findOrFail($rep->investment_id);
$inv->status = 1;
$inv->save();
}
$rep->save();我期望cron作业脚本运行,结果应该是用户在原始投资中的更新
发布于 2019-05-22 16:21:34
我不认为异常消息与cron-job工作有关,它似乎是您的对象有一个空属性。检查并记录$rep->invest的值,如果为空,则检查$rep->invest>plan的值以找出您的问题。
我认为其中一个可能是空的。然后,在修复它们之后,您可能会遇到与cron-job相关的其他问题,但这是另一回事。祝你好运。
发布于 2019-05-22 16:27:37
你可以尝试$reptime‘’invest‘等...
但要将其转换为对象,请使用以下代码:
json_encode($rep)
因为$rep可能是一个数组。
祝好运!
https://stackoverflow.com/questions/56251186
复制相似问题