123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- # 订单类
- namespace Goods\Lib;
- use Dever;
- class Order
- {
- # 获取我的订单
- public function getMyList($uid, $type = false, $type_id = false, $callback = false)
- {
- $where['uid'] = $uid;
-
- if ($type && $type_id) {
- $where['type'] = $type;
- $where['type_id'] = $type_id;
- }
- return $this->getData($where, $callback);
- }
- # 获取某个商品的订单
- public function getList($info_id, $type = false, $type_id = false, $callback = false)
- {
- $where['info_id'] = $info_id;
- if ($type && $type_id) {
- $where['type'] = $type;
- $where['type_id'] = $type_id;
- }
- return $this->getData($where, $callback);
- }
- public function getData($where, $callback = false)
- {
- $order = Dever::db('goods/order')->getData($where);
- if ($order) {
- $config = Dever::db('goods/order')->config['get_status'];
- foreach ($order as $k => $v) {
- $order[$k]['status_name'] = $config[$v['status']];
- $goods = Dever::db('goods/info')->one($v['info_id']);
- $order[$k]['pic'] = $goods['pic_cover'];
- $order[$k]['date'] = date('Y-m-d H:i:s', $v['cdate']);
- $order[$k]['price'] = $v['cash'] * $v['num'] . '元';
- if ($callback) {
- $order[$k] = $callback($order[$k]);
- }
- }
- }
- return $order;
- }
- # 验证是否买过
- public function checkBuy($uid, $goods_id)
- {
- $where['uid'] = $uid;
- $where['info_id'] = $goods_id;
- $where['status'] = 2;
- return Dever::db('goods/order')->one($where);
- }
- }
|