123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\synth\controller;
- use app\common\model\ActivityApply;
- use app\common\model\StoreOrderRefund;
- use library\Controller;
- use think\Db;
- class BillApply extends Controller
- {
- protected $table = 'BillApply';
- /**
- * 列表
- * @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 index()
- {
- $this->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;
- $order_info = ActivityApply::where('id',$data['order_id'])->find()->toArray();
- $data['order_info'] = $order_info;
- 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;
- }
- }
- }
|