|
@@ -9,29 +9,45 @@ use Dever;
|
|
|
class Order
|
|
|
{
|
|
|
# 获取我的订单
|
|
|
- public function getList($uid, $type = false, $type_id = false)
|
|
|
+ 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) {
|
|
|
- if ($v['status'] == 1) {
|
|
|
- $order[$k]['status_name'] = '待支付';
|
|
|
- } elseif ($v['status'] == 2) {
|
|
|
- $order[$k]['status_name'] = '已支付';
|
|
|
- } else {
|
|
|
- $order[$k]['status_name'] = '支付失败';
|
|
|
- }
|
|
|
+ $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]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|