OrderModel.php 946 字节
<?php
/**
 * Created by PhpStorm.
 * User: 29925
 * Date: 2018/8/16
 * Time: 15:21
 */

namespace app\admin\model;

use think\Model;

class OrderModel extends Model
{

    protected $autoWriteTimestamp = true;

    /**
     * 添加订单
     */
    public function addOrder($data) {
        $this->allowField(true)->data($data,true)->isUpdate(false)->save();
        return $this;
    }

    /**
     * 编辑订单
     */
    public function editOrder($data) {
        $this->allowField(true)->data($data,true)->isUpdate(true)->save();
        return $this;
    }

    /**
     * 查询订单
     */
    public function getOrder($where) {
        $where['o.delete_time'] = 0;
        return $this->alias('o')
            ->field(['o.*,ms.user_login,os.name'])
            ->join('__MEMBER_SALES__ ms','o.user_id = ms.id')
            ->join('__ORDER_SORT__ os','os.id = o.sort_id')
            ->where($where)
            ->select();
    }
}