repository = $repository; } /** * @return mixed * @author Qinii * @day 2020-06-12 */ public function lst() { list($page,$limit) = $this->getPage(); $where = $this->request->params(['refund_order_sn','status','refund_type','date','order_sn']); $where['mer_id'] = $this->request->merId(); return app('json')->success($this->repository->getList($where,$page,$limit)); } /** * @param $id * @return mixed * @author Qinii * @day 2020-06-12 */ public function detail($id) { if(!$this->repository->getExistsById($this->request->merId(),$id)) return app('json')->fail('数据不存在'); $data=$this->repository->getOne($id); return app('json')->success($data); } /** * @param $id * @return mixed * @author Qinii * @day 2020-06-12 */ public function switchStatus($id) { if(!$this->repository->getStatusExists($this->request->merId(),$id)) return app('json')->fail('信息或状态错误'); $status=-1; if($this->request->param('status') == 1){ $status=1; }else if($this->request->param('status') == 2){ $status=2; } // $status = ($this->request->param('status') == 1) ? 1 : -1; if($status == 1 || $status == 2){ $refund_order=$this->repository->get($id); if($status==2){ $part_refund_message = $this->request->param('part_refund_message',''); $refund_price =(float) $this->request->param('part_refund_price',0); if($refund_price<0.01){ return app('json')->fail('退款金额不能小于0.01'); } $pay_price=Db::name('store_order')->where('order_id',$refund_order['order_id'])->value('pay_price'); if($refund_order && $refund_price > $pay_price){ return app('json')->fail('退款金额不能大于用户支付金额'); } if($part_refund_message==''){ return app('json')->fail('请填写商家备注'); } $this->repository->update($id,['refund_type'=>1,'refund_price'=>$refund_price,'part_refund_price'=>$refund_price,'part_refund_message' => $part_refund_message,'part_refund_time'=>date('Y-m-d H:i:s')]); } $douduo = $this -> repository -> douduofund($id,true); if($douduo['code'] < 0){ return app('json')->fail($douduo['message']); } if($douduo['code'] == 2){ return app('json')->success($douduo['message']); } // $data = $this->request->params(['mer_delivery_user','mer_delivery_address','phone']); $data['mer_delivery_user']=$this->request->param('mer_refund_user',''); $data['mer_delivery_address']=$this->request->param('mer_refund_address',''); $data['phone']=$this->request->param('set_phone',''); if($refund_order['refund_type']==2 && $status == 1 && ($data['mer_delivery_user']=='' || $data['mer_delivery_address']=='' || $data['phone']=='')){ return app('json')->fail('请输入收货人信息'); } $data['status'] = $status; $this->repository->agree($id,$data,$this->request->adminId(),1); }else{ $fail_message = $this->request->param('fail_message',''); if($status == -1 && empty($fail_message)){ return app('json')->fail('未通过必须填写'); } if($fail_message==''){ return app('json')->fail('未通过必须填写'); } $data['status'] = $status; $data['fail_message'] = $fail_message; $this->repository->refuse($id,$data); $this->repository->set_consult(2,$id);//协商记录 } return app('json')->success('审核成功'); } public function switchStatusjhm($id) { $this->repository->agreejhm($id); return app('json')->success('审核成功'); } public function switchStatusnf($id) { $res = $this->repository->agreenf($id); return app('json')->success($res); } public function switchStatusqds($id) { $res = $this->repository->agreeqds($id); return app('json')->success($res); } /** * TODO 收货后确定退款 * @param $id * @return mixed * @author Qinii * @day 2020-06-12 */ public function refundPrice($id) { if(!$this->repository->getRefundPriceExists($this->request->merId(),$id)) return app('json')->fail('信息或状态错误'); if($this->request->param('status') == 2){ $part_refund_message = $this->request->param('part_refund_message',''); $refund_price =(float) $this->request->param('part_refund_price',0); if($refund_price<0.01){ return app('json')->fail('退款金额不能小于0.01'); } $refund_order=$this->repository->get($id); $pay_price=Db::name('store_order')->where('order_id',$refund_order['order_id'])->value('pay_price'); if($refund_price > $pay_price){ return app('json')->fail('退款金额不能大于用户支付金额'); } if($part_refund_message==''){ return app('json')->fail('请填写商家备注'); } $this->repository->update($id,['refund_price'=>$refund_price,'part_refund_price'=>$refund_price,'part_refund_message' => $part_refund_message,'part_refund_time'=>date('Y-m-d H:i:s')]); }else if($this->request->param('status') == -1){ $fail_message = $this->request->param('fail_message',''); if(empty($fail_message)) return app('json')->fail('请输入拒绝原因'); $data['status'] = -1; $data['fail_message'] = $fail_message; $this->repository->refuse($id,$data); $this->repository->set_consult(7,$id);//协商记录 return app('json')->success('拒绝成功'); } $this->repository->set_consult(5,$id);//协商记录 $this->repository->adminRefund($id,$this->request->adminId()); return app('json')->success('退款成功'); } /** * TODO * @param $id * @return mixed * @author Qinii * @day 2020-06-12 */ public function switchStatusForm($id) { if(!$this->repository->getStatusExists($this->request->merId(),$id)) return app('json')->fail('信息或状态错误'); // $douduo = $this -> repository -> douduofund($id,false); // if($douduo['code'] < 0){ // return app('json')->fail($douduo['message']); // } // if($douduo['code'] == 2){ // return app('json')->success($douduo['message']); // } return app('json')->success(formToData($this->repository->statusForm($id))); } /** * TODO * @param $id * @return mixed * @author Qinii * @day 2020-06-18 */ public function delete($id) { if(!$this->repository->getUserDelExists($this->request->merId(),$id)) return app('json')->fail('信息或状态错误'); $this->repository->update($id,['is_system_del' => 1]); return app('json')->success('删除成功'); } /** * TODO * @param $id * @return mixed * @author Qinii * @day 2020-06-18 */ public function markForm($id) { if(!$this->repository->getExistsById($this->request->merId(),$id)) return app('json')->fail('数据不存在'); return app('json')->success(formToData($this->repository->markForm($id))); } /** * TODO * @param $id * @return mixed * @author Qinii * @day 2020-06-18 */ public function mark($id) { if(!$this->repository->getExistsById($this->request->merId(),$id)) return app('json')->fail('数据不存在'); $this->repository->update($id,['mer_mark' => $this->request->param('mer_mark','')]); return app('json')->success('备注成功'); } public function log($id) { list($page,$limit) = $this->getPage(); $make = app()->make(StoreRefundStatusRepository::class); return app('json')->success($make->search($id,$page,$limit)); } public function reList($id) { [$page,$limit] = $this->getPage(); $make = app()->make(MerchantReconciliationRepository::class); if(!$make->getWhereCount(['mer_id' => $this->request->merId(),'reconciliation_id' => $id])) return app('json')->fail('数据不存在'); $where = ['reconciliation_id' => $id,'type' => 1]; return app('json')->success($this->repository->reconList($where,$page,$limit)); } /** * TODO 快递查询 * @param $id * @return mixed * @author Qinii * @day 2020-06-25 */ public function express($id) { // if(!$this->repository->getWhereCount(['refund_order_id' => $id,'status' =>2])) // return app('json')->fail('订单信息或状态错误'); return app('json')->success($this->repository->express($id)); } }