Order.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. # 订单类
  3. namespace Goods\Lib;
  4. use Dever;
  5. class Order
  6. {
  7. # 获取我的订单
  8. public function getMyList($uid, $type = false, $type_id = false, $callback = false)
  9. {
  10. $where['uid'] = $uid;
  11. if ($type && $type_id) {
  12. $where['type'] = $type;
  13. $where['type_id'] = $type_id;
  14. }
  15. return $this->getData($where, $callback);
  16. }
  17. # 获取某个商品的订单
  18. public function getList($info_id, $type = false, $type_id = false, $callback = false)
  19. {
  20. $where['info_id'] = $info_id;
  21. if ($type && $type_id) {
  22. $where['type'] = $type;
  23. $where['type_id'] = $type_id;
  24. }
  25. return $this->getData($where, $callback);
  26. }
  27. public function getData($where, $callback = false)
  28. {
  29. $order = Dever::db('goods/order')->getData($where);
  30. if ($order) {
  31. $config = Dever::db('goods/order')->config['get_status'];
  32. foreach ($order as $k => $v) {
  33. $order[$k]['status_name'] = $config[$v['status']];
  34. $goods = Dever::db('goods/info')->one($v['info_id']);
  35. $order[$k]['pic'] = $goods['pic_cover'];
  36. $order[$k]['date'] = date('Y-m-d H:i:s', $v['cdate']);
  37. $order[$k]['price'] = $v['cash'] * $v['num'] . '元';
  38. if ($callback) {
  39. $order[$k] = $callback($order[$k]);
  40. }
  41. }
  42. }
  43. return $order;
  44. }
  45. # 验证是否买过
  46. public function checkBuy($uid, $goods_id)
  47. {
  48. $where['uid'] = $uid;
  49. $where['info_id'] = $goods_id;
  50. $where['status'] = 2;
  51. return Dever::db('goods/order')->one($where);
  52. }
  53. }