where('province_id',$data['province_id']); } if(!empty($data['city_id'])){ $model->where('city_id',$data['city_id']); } if(!empty($data['network']) && !empty(MobileConstant::getNetwork()[$data['network']]['search'])){ $model->whereIn('network',MobileConstant::getNetwork()[$data['network']]['search']); } $list=$model->with(['info']) ->where('s_id',$this->auth->id) ->order('id','desc') ->paginate(); $this->assign('list',$list); $this->assign('status',$model::$status); $this->assign('network',MobileConstant::getNetwork()); return view(); } public function index(){ $data=input(); $page=input('page',1); $limit=input('limit',15); $export=input('export'); $model=(new MobileOrder()) ->where('s_id',$this->auth->id); if(!empty($data['order_no'])){ $model->where('order_no',$data['order_no']); } $model ->with(['info']) ->order('id','desc'); $extend=[]; if($export){ return MobileOrderExport::export((clone $model)->paginate($limit)); }else{ $extend['total']=(clone $model)->sum('amount'); $extend['alipay']=(clone $model)->where('pay_type',1)->sum('amount'); $extend['wechat']=(clone $model)->where('pay_type',2)->sum('amount'); $extend['jd']=(clone $model)->where('pay_type',3)->sum('amount'); $extend['di']=(clone $model)->sum('amount_di'); $extend['profit']=(clone $model)->sum('amount_profit'); $extend['refund']=(clone $model)->sum('amount_refund'); } $list=$model->paginate($limit); $this->assign('list',$list); $this->assign('extend',$extend); $this->assign('pay_type',MobileOrder::$payTypes); $this->assign('status',MobileOrder::$status); return view(); } #退款 public function refund(){ $id=input('id',0); $data=input(); if($this->request->isGet()){ $model=MobileOrder::where('s_id',$this->auth->id)->find($id); $this->assign('row',$model); return view(); }else{ $this->validate($data,RefundValidate::class); Db::startTrans(); $model=MobileOrder::where('s_id',$this->auth->id)->where('id',$id)->lock(true)->findOrFail(); $model->makeRefund('user',$this->auth->getUser(),$data); Db::commit(); $this->success(); } } #退款记录 public function refund_log(){ $id=input('id',0); $model=MobileOrder::where('s_id',$this->auth->id)->find($id); $list=$model->refundLog() ->with(['refunduser']) ->paginate(); $this->assign('list',$list); return view(); } #备注 public function remark(){ $id=input('id',0); $model=MobileOrder::where('s_id',$this->auth->id)->find($id); if($this->request->isGet()) { return view('', compact('model')); }else{ $remark_sub=input('remark_sub'); $model['remark_sub']=$remark_sub; $model->save(); $this->success(); } } }