uuid(); $count = ['待付款','待发货','待收货','退款/售后']; foreach ($count as &$v){ switch ($v){ case '待付款': $array = [2]; break; case '待发货': $array = [4]; break; case '待收货': $array = [5]; break; case '退款/售后': $array = [6,7]; break; } $v=ShopOrder::mk()->where('admin_id',$admin_id->id)->whereIn('status',$array)->count(); } $this->success('商城订单上标数量',$count); } /** * @Title ("商城订单上标数量") * @Method ("get") * @return void * @throws \think\db\exception\DbException */ public function order_count(){ $admin_id=$this->uuid(); $count = ['全部','待付款','待发货','待收货']; foreach ($count as &$v){ switch ($v){ case '全部': $array = [0,1,2,3,4,5]; break; case 2: $array = [2]; break; case 3: $array = [4]; break; case 4: $array = [5]; break; } $v=ShopOrder::mk()->where('admin_id',$admin_id->id)->whereIn('status',$array)->count(); } $this->success('商城订单上标数量',$count); } /** * @Title("我的订单") * @Method("post") * @Param ("page",desc="页码") * @Param("order_name",desc="搜索名称") * @Param ("status",desc="1全部 2 待支付 3代发货 4 待收货") */ public function order_list(){ $admin_id=$this->uuid(); $status = input('status',1); if(!empty($status)){ switch ($status){ case 1: $array = [0,1,2,3,4,5,6]; break; case 2: $array = [2]; break; case 3: $array = [4]; break; case 4: $array = [5]; break; } } $query = ShopOrder::mQuery()->like('order_name'); $list = $query ->where('admin_id',$admin_id['id']) ->whereIn('status',$array)->order('id desc')->page(true, false, false, 10); foreach ($list['list'] as $k=>$v){ $list['list'][$k]['goods_item']=ShopOrderItem::mk()->where('order_no',$list['list'][$k]['order_no'])->select(); $list['list'][$k]['user_address']=ShopOrderSend::mk()->where('order_no',$list['list'][$k]['order_no'])->find(); } $this->success('店铺订单列表',$list); } /** * @Title ("订单详情") * @Method ("post") * @Param ("order_id",desc="订单id") * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function order_info(){ $admin_id=$this->uuid(); $order_id = input('order_id'); $list = ShopOrder::mk()->where('admin_id',$admin_id['id'])->where('id',$order_id)->find(); $list['time']=0; if($list['status']==2){ $list['time'] = strtotime($list['create_at'])+30*60-time(); } $list['user']=DataUser::mk()->where('id',$list['uuid'])->field('nickname,phone')->find(); $list['goods_item']=ShopOrderItem::mk()->where('order_no',$list['order_no'])->select(); $list['user_address']=ShopOrderSend::mk()->where('order_no',$list['order_no'])->find(); $this->success('店铺订单列表',$list); } /** * @Title ("退款订单列表") * @Method ("get") * @Param ("page",desc="页码") * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function refund_list(){ $admin_id=$this->uuid(); $status =[7,8]; $query = ShopOrder::mQuery()->like('order_name'); $list = $query ->where('admin_id',$admin_id['id']) ->whereIn('status',$status)->order('id desc')->page(true, false, false, 10); foreach ($list['list'] as $k=>$v){ $list['list'][$k]['goods_item']=ShopOrderItem::mk()->where('order_no',$list['list'][$k]['order_no'])->select(); $list['list'][$k]['user_address']=ShopOrderSend::mk()->where('order_no',$list['list'][$k]['order_no'])->find(); } $this->success('退款订单',$list); } /** * @Title ("退款操作接口") * @Method ("post") * @Param ("order_id",desc="订单id") * @Param ("type",desc="退款操作 type=1同意退款 type=2 不同意驳回") * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function examine_refund(){ $admnd_id=$this->uuid(); $data = $this->_vali([ 'order_id.require'=>'退款订单不能为空', 'type.require'=>'操作类型能为空' ]); $info = ShopOrder::mk()->where(['id'=>$data['order_id'],'admin_id'=>$admnd_id['id'],'status'=>7])->find(); if(empty($info)){ $this->error('订单信息有误'); } else{ // 退款操作 if($data['type']==1){ //同意退款 ShopOrder::mk()->where(['id'=>$data['order_id'],'admin_id'=>$admnd_id['id']])->save(['status'=>8,'refund_status'=>4,'dk_time'=>date('Y-m-d H:i:s')]); $this->success('已同意退款,支付金额原路退回'); } else if($data['type']==1){ ShopOrder::mk()->where(['id'=>$data['order_id'],'admin_id'=>$admnd_id['id']])->save(['status'=>5]); //不同意退款 $this->success('已驳回用户退款申请'); } //统一退货 else { ShopOrder::mk()->where(['id'=>$data['order_id'],'admin_id'=>$admnd_id['id']])->save(['refund_status'=>2]); //不同意退款 $this->success('同意退货'); } } } /** * @Title ("立即发货") * @Method ("post") * @Param ("order_no",desc="订单编号") * @Param ("send_number",desc="快递编号") * @Param ("company_name",desc="快递公司") * @Param ("name",desc="发货姓名") * @Param ("pone",desc="发货联系号码") * @Param ("province",desc="省") * @Param ("city",desc="城市") * @Param ("area",desc="地区") * @Param ("address",desc="详细地址") * @return void */ public function order_send(){ $admin_id = $this->uuid(); $data = $this->_vali( [ 'order_no'=>'订单信息不能为空', 'send_number.require'=>'快递单号不能为空', 'company_name.require'=>'快递公司名称不能为空', 'name.require'=>'发货商家联系人', 'pone.require'=>'商家联系号码', 'province.require'=>'发货商家省', 'city.require'=>'商家市', 'area.require'=>'发货商家区县', 'address.require'=>'详细地址' ] ); $send_data = [ 'send_number'=>$data['send_number'], 'company_name'=>$data['company_name'], 'send_datetime'=>date('Y-m-d H:i:s'), 'fa_name'=>$data['name'], 'fa_phone'=>$data['phone'], 'fa_address'=>$data['province'].$data['city'].$data['area'].$data['address'], 'shou_name'=>$data['name'], 'shou_phone'=>$data['phone'], 'shou_address'=>$data['province'].$data['city'].$data['area'].$data['address'], ]; ShopOrderSend::mk()->where('order_no',$data['order_no'])->save($send_data); ShopOrder::mk()->where('order_no',$data['order_no'])->save(['status'=>5]); $this->success('发货成功'); } public function uuid(){ $purchase_model = new Common($this->app); $uuid = $purchase_model->uuid(); return $uuid; } }