OrderController.php 10.0 KB
<?php
namespace api\portal\controller;
use think\Controller;
use think\Db;

/**
 * @title 后台订单
 * @description 后台订单相关接口
 */
class OrderController extends Controller
{
    /**
     * @title 营销订单
     * @description
     * @author panhaowen
     * @url /portal/Order/marketOrderIndex
     * @param name:param type:varchar require:1 desc:搜索参数(order_sn,media,user_login1,status)
     * @method POST
     */
    public function marketOrderIndex()
    {
        $param=$this->request->param();
        $where=[];
        if (!empty($param['order_sn'])){
            $where['mo.order_sn']=['like','%'.$param['order_sn'].'%'];
        }
        if (!empty($param['media'])){
            $where['m.media']=['like','%'.$param['media'].'%'];
        }
        if (!empty($param['user_login1'])){
            $where['u1.user_login']=['like','%'.$param['user_login1'].'%'];
        }
        if (!empty($param['status'])){
            $where['mo.status']=$param['status'];
        }
        $data=Db::name('market_order')
            ->alias('mo')
            ->join('user u1','mo.user_id=u1.id')
            ->join('user u2','mo.admin_id=u2.id')
            ->join('market_business m','mo.market_business_id=m.id')
            ->where($where)
            ->field('mo.*,u1.user_login as user_login1,u2.user_login as user_login2,m.plant,u1.user_type,m.media')
            ->paginate('10');
        $this->success('获取信息成功',$data);
    }


    /**
     * @title 查看营销订单
     * @description
     * @author panhaowen
     * @url /portal/Order/OrderCheck
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function OrderCheck()
    {
        $param=$this->request->param();
        $data=Db::name('market_order')->where('id',$param['id'])->find();
        $data['more']=cmf_get_file_download_url($data['more']);
        $this->success('获取信息成功',$data);
    }

    /**
     * @title 通过营销订单
     * @description
     * @author panhaowen
     * @url /portal/Order/OrderPass
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function OrderPass()
    {
        $param=$this->request->param();
        $user=$this->getUser();
        $re=Db::name('market_order')->where('id',$param['id'])->update(['status'=>2,'admin_id'=>$user['id']]);
        if ($re){
            $this->success('操作成功');
        }else{
            $this->error('操作失败');
        }
    }

    /**
     * @title 驳回营销订单
     * @description
     * @author panhaowen
     * @url /portal/Order/OrderReturn
     * @param name:id type:int require:1 desc:订单id
     * @param name:return type:varchar require:1 desc:驳回原因
     * @method POST
     */
    public function OrderReturn()
    {
        $param=$this->request->param();
        $admin=$this->getUser();
        $re=Db::name('market_order')->where('id',$param['id'])->update(['status'=>3,'return'=>$param['return'],'admin_id'=>$admin['id']]);
        $order=Db::name('market_order')->where('id',$param['id'])->find();
        Db::name('user')->where('id',$order['user_id'])->setInc('money',$order['money']);
        $user=Db::name('user')->where('id',$order['user_id'])->find();
        Db::name('money_log')->insert(['type'=>4,'create_time'=>time(),'money'=>$order['money'],'remark'=>$param['return'],'now_money'=>$user['money'],'user_id'=>$user['id']]);
        if ($re){
            $this->success('操作成功');
        }else{
            $this->error('操作失败');
        }
    }

    /**
     * @title 驳回营销订单原因
     * @description
     * @author panhaowen
     * @url /portal/Order/OrderReturnDetail
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function OrderReturnDetail()
    {
        $param=$this->request->param();
        $data=Db::name('market_order')->where('id',$param['id'])->find();
        $this->success('获取数据成功',$data['return']);
    }

    /**
     * @title 发布营销订单
     * @description
     * @author panhaowen
     * @url /portal/Order/OrderShow
     * @param name:id type:int require:1 desc:订单id
     * @param name:param type:varchar require:1 desc:发布内容(url链接,remark文件)
     * @method POST
     */
    public function OrderShow()
    {
        $param=$this->request->param();
        $param['status']=4;
        $re=Db::name('market_order')->where('id',$param['id'])->update($param);
        if ($re){
            $this->success('操作成功');
        }else{
            $this->error('操作失败');
        }
    }

    /**
     * @title 发布营销订单详情
     * @description
     * @author panhaowen
     * @url /portal/Order/OrderShowDetail
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function OrderShowDetail()
    {
        $param=$this->request->param();
        $data=Db::name('market_order')->where('id',$param['id'])->find();
        if (empty($data['remark'])){
            $this->success('获取数据成功',$data['url']);
        }else{
            $this->success('获取数据成功',cmf_get_file_download_url($data['remark']));
        }
    }


    /**
     * @title 新媒体订单
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderIndex
     * @param name:param type:varchar require:1 desc:搜索参数(order_sn,name,user_login1,status)
     * @method POST
     */
    public function businessOrderIndex()
    {
        $param=$this->request->param();
        $where=[];
        if (!empty($param['order_sn'])){
            $where['bo.order_sn']=['like','%'.$param['order_sn'].'%'];
        }
        if (!empty($param['name'])){
            $where['b.name']=['like','%'.$param['name'].'%'];
        }
        if (!empty($param['user_login1'])){
            $where['u1.user_login']=['like','%'.$param['user_login1'].'%'];
        }
        if (!empty($param['status'])){
            $where['bo.status']=$param['status'];
        }
        $data=Db::name('business_order')
            ->alias('bo')
            ->join('user u1','bo.user_id=u1.id')
            ->join('user u2','bo.admin_id=u2.id')
            ->join('business b','bo.business_id=b.id')
            ->where($where)
            ->field('bo.*,u1.user_login as user_login1,u2.user_login as user_login2,u1.user_type,b.name')
            ->paginate('10');
        $this->success('获取信息成功',$data);
    }

    /**
     * @title 新媒体订单接收
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderPass
     * @param name:id type:int require:1 desc:新媒体订单id
     * @method POST
     */
    public function businessOrderPass()
    {
        $param=$this->request->param();
        $user=$this->getUser();
        $re=Db::name('business_order')->where('id',$param['id'])->update(['status'=>2,'admin_id'=>$user['id']]);
        if ($re){
            $this->success('操作成功');
        }else{
            $this->error('操作失败');
        }
    }

    /**
     * @title 新媒体订单驳回
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderReturn
     * @param name:id type:int require:1 desc:新媒体订单id
     * @param name:return type:varchar require:1 desc:驳回原因
     * @method POST
     */
    public function businessOrderReturn()
    {
        $param=$this->request->param();
        $user=$this->getUser();

        $re=Db::name('business_order')->where('id',$param['id'])->update(['status'=>3,'admin_id'=>$user['id'],'return'=>$param['return']]);
        $user=Db::name('business_order')->where('id',$param['id'])->find();
        Db::name('user')->where('id',$user['id'])->setInc('money',$user['money']);
        if ($re){
            $this->success('操作成功');
        }else{
            $this->error('操作失败');
        }
    }
    /**
     * @title 驳回新媒体订单原因
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderReturnDetail
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function businessOrderReturnDetail()
    {
        $param=$this->request->param();
        $data=Db::name('business_order')->where('id',$param['id'])->find();
        $this->success('获取数据成功',$data['return']);
    }

    /**
     * @title 新媒体订单留言(留言类 )
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderLiuyan
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function businessOrderLiuyan()
    {
        $param=$this->request->param();
        $data=Db::name('business_order')->where('id',$param['id'])->find();
        $this->success('获取数据成功',$data['liuyan']);
    }

    /**
     * @title 完成新媒体订单
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderShow
     * @param name:id type:int require:1 desc:订单id
     * @param name:param type:varchar require:1 desc:发布内容(url链接,remark文件)
     * @method POST
     */
    public function businessOrderShow()
    {
        $param=$this->request->param();
        $param['status']=4;
        $param['end_time']=time();
        $re=Db::name('business_order')->where('id',$param['id'])->update($param);
        if ($re){
            $this->success('操作成功');
        }else{
            $this->error('操作失败');
        }
    }

    /**
     * @title 完成新媒体订单详情
     * @description
     * @author panhaowen
     * @url /portal/Order/businessOrderShowDetail
     * @param name:id type:int require:1 desc:订单id
     * @method POST
     */
    public function businessOrderShowDetail()
    {
        $param=$this->request->param();
        $data=Db::name('business_order')->where('id',$param['id'])->find();
        if (empty($data['remark'])){
            $this->success('获取数据成功',$data['url']);
        }else{
            $this->success('获取数据成功',cmf_get_file_download_url($data['remark']));
        }
    }
}