<?php namespace Content\Lib;
use Dever;
use Place;
# 内容订单只需买一次就可以了，所以只需要保留成功订单
class Order
{
    # 获取订单信息
    public function getInfo($info)
    {
        # 需要定期清理status=1的订单
        $info['scash'] = $info['cash'];
        $info['cash'] = Dever::load('price', 'place')->getText($info['cash'], 3);
        $detail['id'] = $info['id'];
        $detail['name'] = $info['name'];
        $detail['pic'] = $info['pic'];
        $detail['sku_name'] = '';
        $detail['sku_id'] = 0;
        $detail['cash'] = $info['cash'];
        $detail['num'] = $info['num'];
        $info['detail'][] = $detail;
        $info['info'] = '';
        return $info;
    }

    # 支付成功
    public function success($order, $status)
    {
        if ($status == 1) {
            $update['pdate'] = time();
            $state = Dever::db('order', 'content')->update($order['id'], $update);
        } else {
            $state = Dever::db('order', 'content')->delete($order['id']);
        }
        return $state;
    }
}