title = '列表'; $query = $this->_query($this->table); $this->type_arr = \app\common\model\BillType::getType(); $where= []; $were[] = ['i.is_deleted','=',0]; if($this->request->request('user_name')) $where[]= ['i.name','like','%'.$this->request->request('user_name').'%']; if($this->request->request('header')) $where[]= ['i.header','like','%'.$this->request->request('header').'%']; if($this->request->request('type')) $where[]= ['i.type','=',$this->request->request('type')]; $query->alias('i')->field('i.* ,b.title type_name,m.headimg,m.name as user_name,m.phone') ->Leftjoin('store_member m',' m.id = i.user_id ') ->join('bill_type b',' b.id = i.type ','LEFT'); if(!empty($where)) $query->where($where); $query ->order('i.id desc')->page(); } protected function _index_page_filter(array &$data) { } /** * 删除 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function remove() { $this->_save($this->table, ['is_deleted' => '1']); } /** * 编辑 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '编辑'; $this->_form($this->table, 'form'); } /** * 表单数据处理 * @auth true * @menu true * @param array $data */ protected function _form_filter(&$data) { if ($this->request->isGet() && $this->request->action() == 'edit'){ // 退款金额 $refund_money = StoreOrderRefund::getRefundMoney($data['order_id'],1); $data['refund_money'] = $refund_money; if($data['order_type'] == 1) $order_info = LevelOrder::where('id',$data['order_id'])->find()->toArray(); if($data['order_type'] == 2) $order_info = GoodsOrder::where('id',$data['order_id'])->find()->toArray(); if($data['order_type'] == 3) $order_info = ActivityApply::where('id',$data['order_id'])->find()->toArray(); $data['order_info'] = $order_info; $data['type_name'] = \app\common\model\BillType::where('id',$data['type'])->value('title'); if($data['address_info']) $data['address_info'] = json_decode($data['address_info'],true); $this->data = $data; } if ($this->request->isPost() && $this->request->action() == 'deliver') { $express_company = Db::name('express_company')->field('id,express_title')->find($data['express_company_id']); $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : ''; $data['express_send_at'] = date("Y-m-d H:i:s"); $data['express_state'] = 1; } } /** * 修改快递 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function express() { if ($this->request->isGet()) { $where = ['is_deleted' => '0', 'status' => '1']; $this->expressList = Db::name('express_company')->where($where)->order('sort desc,id desc')->select(); $info = \app\common\model\BillApply::where('id',input('id'))->find(); if($info['address_info']) $info['address_info'] = json_decode($info['address_info'],true); $this->vo = $info; } $this->_form($this->table); } /** * 快递表单处理 * @param array $vo * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _express_form_filter(&$vo) { if ($this->request->isPost()) { $order = Db::name($this->table)->where(['id' => $vo['id']])->find(); if (empty($order)) $this->error('订单查询异常,请稍候再试!'); $express = Db::name('express_company')->where(['express_code' => $vo['express_company_code']])->find(); if (empty($express)) $this->error('发货快递公司异常,请重新选择快递公司!'); $vo['express_company_title'] = $express['express_title']; $vo['express_send_at'] = empty($order['express_send_at']) ? date('Y-m-d H:i:s') : $order['express_send_at']; $vo['express_state'] = '1'; $vo['status'] = '1'; $vo['bill_time'] = date("Y-m-d H:i:s"); $info = \app\common\model\BillApply::where('b.id', $vo['id'])->alias('b')->field('b.user_id,y.act_id') ->leftJoin('ActivityApply y','y.id = b.order_id')->find()->toArray(); UserMessage::sendUserMessage($info['user_id'],'activity',5,1,0,$info['act_id'],'',$vo['id']); } } public function billImageSave() { if($this->request->isPost()) { $id = input('post.id'); $bill_img = input('post.bill_img'); \app\common\model\BillApply::where('id',$id)->update(['bill_img'=>$bill_img,'bill_time'=>date("Y-m-d H:i:s"),'status'=>1]); $info = \app\common\model\BillApply::where('b.id',$id)->alias('b')->field('b.user_id,y.act_id') ->leftJoin('ActivityApply y','y.id = b.order_id')->find()->toArray(); UserMessage::sendUserMessage($info['user_id'],'activity',5,0,0,$info['act_id'],'',$id); $this->success('保存成功'); } } }