select(); $list = $userPledge::alias('a') ->join('product_pledge b', 'a.pledge_id = b.id', 'left') ->where('a.status', '>', 0) ->field('a.*,b.day_num') ->select(); $i = 0; $time= time(); $day = 86400; foreach ($list as $item) { if($item->status == 1) { //未接触收益 $reta = bcdiv($item->day_num, $day, 6); //天数 $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间 $total_inco = bcmul($reta, $inter, 6) * $item->num; //累计收益 $item->last_time = $time; //收取时间 $item->total_self= bcadd($total_inco, $item->total_self, 2); //累计收益 $total = $total_inco; //累计收益 } if($total > 0){ //更新用户资产 $ledgerWalletModel->changeWalletAccount($item->user_id, Asset::TEAC, $total, LedgerTeacChangeModel::Pledge, 0); } //修改详情订单状态 $detail = json_decode($item['details'], true); $productOrder::where('status', 6)->whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid); //更新存储订单状态 $item->last_time = $time; $item->status = 0; //关闭 $item->save(); $i++; } $this->success('ok:'. $i); } }