OrderController.php 2.1 KB
<?php
/**
 * Created by PhpStorm.
 * auther: sgj
 * Date: 2020/10/14
 * Time: 17:02
 */

namespace app\admin\controller;


use cmf\controller\AdminBaseController;
use cmf\controller\BaseController;

class OrderController extends AdminBaseController
{
    /**
     * 订单列表
     */
    public function index(){
        $param=$this->request->param();
        $map=[];
        $data= db('orders')->alias('o')
            ->field('v.name as user_name,v.photo,g.*,o.*')
            ->join('goods g','o.good_id=g.id')
            ->join('user u','u.id=o.user_id')
            ->join('volunteer v','v.user_id=o.user_id')
            ->where($map)
            ->order('o.id desc')
            ->paginate();
        $data->appends($param);
        $list=$data->items();
        $this->assign([
            'data'=>$list,
            'page'=>$data->render(),
        ]);
        return $this->fetch();
    }

    public function info(){

    }


    public function edit()
    {
        $id = input('id');
        $param = $this->request->param();
        $map['o.id'] = $id;
        $data = db('orders')->alias('o')
            ->field('v.name as user_name,v.photo,g.*,o.*')
            ->join('goods g', 'o.good_id=g.id')
            ->join('user u', 'u.id=o.user_id')
            ->join('volunteer v', 'v.user_id=o.user_id')
            ->where($map)
            ->find();
        $this->assign('data', $data);
        return $this->fetch();
    }


    public function editPost(){
        $id = input('id');
        $data=input();
        $data['content_info']=htmlspecialchars(cmf_replace_content_file_url(htmlspecialchars_decode($data['content_info']), true));
        $data['remark']=htmlspecialchars(cmf_replace_content_file_url(htmlspecialchars_decode($data['remark']), true));
        $data['reason']=htmlspecialchars(cmf_replace_content_file_url(htmlspecialchars_decode($data['reason']), true));
        $result=db('orders')->where('id',$id)->update($data);
        if ($result){
            $this->success('编辑成功');
        }else{
            $this->success('编辑成功');
        }
    }
}