with(['User' => function ($query) use ($userSelect) { $query->select($userSelect); }]) ->orderByDesc('id') ->groupBy('id') ->select($select); if (!empty($param['type'])) { if($param['type']==4){ $res->whereIn('status',[2,3,4,5,6,9]); $res->where('end_time','<',date('Y-m-d H:i:s')); }else{ $res->where('status', $param['type']); $res->where('end_time','>',date('Y-m-d H:i:s')); } }else{ $res->whereIn('status',[2,3,4,5,6,9]); } $r=$res->paginate(perPage()); if($r->isNotEmpty()){ collect($r->items())->each(function ($item, $key) { if($item->end_timestatus=9; } $allowarea=Proxy::whereProvince($item->province)->whereUid(0)->where('city',$item->city)->where('district',$item->district)->whereStatus(1)->count(); $item->allowdArea=$allowarea;//0地区冻结 >0未冻结 if($item->guarantee==1){ $item->bet=\DB::table('advertising_bet')->where('advertising_id','=',$item->id)->first(); } }); } return $r; } /** * 更新广告位状态 * @author lyh * @date 2019/3/22 * @date 2019/3/22 * @param $out_trade_no * @param $price * @param $status * @param $payType * @description */ public static function updateAdver($out_trade_no) { $adver = Advertising::whereOrderNo($out_trade_no)->first(); if (empty($adver)) { ErrorLog::saveMsg("广告位订单号[{$out_trade_no}]不存在"); } /* if ($adver->status!=1) { return; }*/ $adverUpdate = Advertising::whereOrderNo($out_trade_no)->update([ 'status' => 2 ]); // 生成流水日志 AccountLog::saveData(6, '-'.$adver->total_price, 0, 2, 0, "购买广告位花费".$adver->total_price.'元'); if (empty($adverUpdate)) { ErrorLog::saveMsg("广告位订单号[{$out_trade_no}]状态更新为待审核失败"); } // 修改活动记录状态 if ($adver->activity_id) { AdverActivityLog::whereId($adver->activity_id)->update(['status' => 2]); } } /** * @author lyh * @date 2019/3/21 * @description */ public function User() { return $this->hasOne('App\Modes\User', 'id', 'uid'); } public function Industry() { return $this->hasOne('App\Modes\Industry', 'id', 'company_industry'); } }