OrderTrade.php 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\common\model\order;
  3. use app\common\model\BaseModel;
  4. /**
  5. * Class OrderTrade
  6. */
  7. class OrderTrade extends BaseModel
  8. {
  9. protected $name = 'order_trade';
  10. protected $pk = 'id';
  11. /**
  12. * 关联订单表
  13. */
  14. public function orderList()
  15. {
  16. return $this->hasMany('app\\common\\model\\order\\Order', 'order_id', 'order_id');
  17. }
  18. /**
  19. * 详情
  20. */
  21. public static function detail($where, $with = [])
  22. {
  23. is_array($where) ? $filter = $where : $filter['id'] = (int)$where;
  24. return (new static())->with($with)->where($filter)->find();
  25. }
  26. /**
  27. * 详情
  28. */
  29. public static function detailWithOrder($where)
  30. {
  31. $list = (new static())->where($where)->select();
  32. $orderList = [];
  33. foreach ($list as $trade){
  34. array_push($orderList, Order::detail($trade['order_id']));
  35. }
  36. return $orderList;
  37. }
  38. }