PortalController.php 6.3 KB
<?php
namespace api\portal\controller;
use think\Controller;
use think\Db;

/**
 * @title  前台补充
 * @description 前台补充接口
 */
class PortalController extends Controller
{
    /**
 * @title 营销下单
 * @description
 * @author panhaowen
 * @url /portal/portal/marketOrderAdd
 * @param name:id type:int require:1 desc:营销id
 * @param name:file type:varchar require:1 desc:上传文件
 * @param name:money type:int require:1 desc:订单金额
 * @method POST
 */
    public function marketOrderAdd()
    {
        $param=$this->request->param();
        $user=$this->getUser();
        if ($user['money']<$param['money']){
            $this->error('账号余额不足');
        }
        foreach ($param['id'] as $v){
            $money=Db::name('market_business')->where('id',$v);
            Db::name('market_order')->insert(['market_business_id'=>$v,'create_time'=>time(),'order_sn'=>cmf_get_order_sn(),'more'=>$param['file'],'money'=>$money,'user_id'=>$user['id']]);
        }
        Db::name('user')->where('id',$user['id'])->setDec('money',$param['money']);
        Db::name('money_log')->insert(['type'=>3,'create_time'=>time(),'user_id'=>$user['id'],'money'=>$param['money'],'now_money'=>($user['money']-$param['money'])]);
        $this->success('操作成功');
    }

    /**
     * @title 新媒体下单
     * @description
     * @author panhaowen
     * @url /portal/portal/businessOrderAdd
     * @param name:business_id type:int require:1 desc:新媒体id
     * @param name:count type:varchar require:1 desc:购买数量
     * @param name:money type:int require:1 desc:订单金额
     * @param name:post_url type:varchar require:0 desc:文章地址
     * @param name:more type:varchar require:0 desc:文件上传
     * @param name:content   type:varchar require:0 desc:备注
     * @param name:liuyan type:varchar require:0 desc:留言
     * @method POST
     */
    public function businessOrderAdd()
    {
        $param=$this->request->param();
        $user=$this->getUser();
        if ($user['money']<$param['money']){
            $this->error('账号余额不足');
        }
        $param['create_time']=time();
        $param['create_time']=cmf_get_order_sn();
        $param['user_id']=$user['id'];
        Db::name('business_order')->insert($param);
        Db::name('user')->where('id',$user['id'])->setDec('money',$param['money']);
        Db::name('money_log')->insert(['type'=>2,'create_time'=>time(),'user_id'=>$user['id'],'money'=>$param['money'],'now_money'=>($user['money']-$param['money'])]);
        $this->success('操作成功');
    }

    /**
     * @title 订单列表种类
     * @description
     * @author panhaowen
     * @url /portal/portal/Order
     * @method POST
     */
    public function Order()
    {
        $data=Db::name('category')->select();
        $this->success('获取信息成功',$data);
    }


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

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


    /**
     * @title 营销订单重投
     * @description
     * @author panhaowen
     * @url /portal/portal/MarketOrderRe
     * @method POST
     * @param name:id type:int require:1 desc:营销订单id
     * @param name:file type:varchar require:1 desc:文件上传
     */
    public function MarketOrderRe()
    {
        $param=$this->request->param();
        $user=$this->getUser();
        $order=Db::name('market_order')->where('id',$param['id'])->find();
        if ($user['money']<$order['money']){
            $this->error('账户余额不足');
        }
        Db::name('market_order')->insert(['market_business_id'=>$order['market_business_id'],'create_time'=>time(),'order_sn'=>cmf_get_order_sn(),'more'=>$param['file'],'money'=>$order['money'],'user_id'=>$user['id']]);
        Db::name('user')->where('id',$user['id'])->setDec('money',$order['money']);
        Db::name('money_log')->insert(['type'=>3,'create_time'=>time(),'user_id'=>$user['id'],'money'=>$order['money'],'now_money'=>($user['money']-$order['money'])]);
        $this->success('操作成功');
    }

    /**
     * @title 新媒体订单查看内容
     * @description
     * @author panhaowen
     * @url /portal/portal/BusinessOrder
     * @method POST
     * @param name:id type:int require:1 desc:新媒体订单id
     */
    public function BusinessOrder()
    {
        $param=$this->request->param();
        $data=Db::name('business_order')->where('id',$param['id'])->find();
        if ($data['post_url']!=null) {
            $this->success('获取信息成功', $data['post_url']);
        }
        $this->success('获取信息成功', cmf_get_file_download_url($data['remark']));
    }

    /**
     * @title 新媒体订单退款
     * @description
     * @author panhaowen
     * @url /portal/portal/BusinessOrderReturn
     * @method POST
     * @param name:id type:int require:1 desc:新媒体订单id
     */
    public function BusinessOrderReturn()
    {
        $param=$this->request->param();
        $user=$this->getUser();
        $order=Db::name('business_order')->where('id',$param['id'])->find();
        Db::name('business_order')->where('id',$param['id'])->update(['status'=>3]);
        Db::name('user')->where('id',$user)->setInc('money',$order['money']);
        Db::name('money_log')->insert(['create_time'=>time(),'user_id'=>$user['id'],'money'=>$order['money'],'now_money'=>$user['money']+$order['money'],'type'=>5]);
        $this->success('操作成功');
    }
}